but also /item/mime=anything is not a valid url and neither is /item/mime=image/svg+xml
Problem with plus symbol in DB / response header
Hi,
Update: my mistake, the problem is because the plus sign is fetched from the query string, not the db:
// in a blade file
data-url = "/item/mime={{$file->mime}}"
so I used rawurlencode():
// in a blade file
data-url="/item/mime={{rawurlencode($file->mime)}}"
And it works!
---- Original Question ----
I am saving the mime type in the DB, and I need to return it with a response from the controller.
For example, the mime type is image/svg+xml, I can see the plus symbol in the db.
But when I do:
$mime = DB::table('table')->find(1)->mime;
return response('success')->header('Content-Type', $mime);
If I dd($mime), it shows image/svg xml instead of image/svg+xml (And also the response headers in the browser show the same)
I am not sure if my problem is how I save it in the DB and maybe I need to decode it first, or the problem is when I fetch it back. Because I do see the plus symbol in the DB (MySQL, MySQL Workbench)
Thanks
Please or to participate in this conversation.