julienmru's avatar

Uploaded SVG files stored as HTML?

Hi there,

I have a simple controller with the following code:

    if ($request->hasFile('file')) {
      $path = $request->file->store('images');
    }

When I upload a SVG file, $path contains a .html file and the file is indeed stored as .html on the server. I have no middleware.

Here's a snippet of the request (the mime-type looks good to me):

------WebKitFormBoundarywRanlLzAku4jBaQO
Content-Disposition: form-data; name="file"; filename="bubbles.svg"
Content-Type: image/svg+xml


------WebKitFormBoundarywRanlLzAku4jBaQO--

Thanks.

0 likes
5 replies
exwi's avatar

Have you tried manually setting the file name?

julienmru's avatar

@exwi : I have various image types to be upload (eg. jpeg which cause no issue), so I'd prefer automatic file name setting by Laravel.

julienmru's avatar

FYI I uploaded the code to a staging server (with settings not 100% the same as my development machine) and I have the exact same issue.

julienmru's avatar

It's actually weirder than I thought. storeAs didn't store as SVG file either but as an HTML file. Here's the file which wouldn't upload as SVG: https://ufile.io/dxnlu

Please or to participate in this conversation.