It would seem that maybe your method of getClientOriginalExtension() is the problem because you stated the extension may not be correct. One thing you could do is dd($fileExtension): to make sure it is what you expected. If not, then the method is the problem.
Dec 12, 2016
5
Level 5
Uploaded file damaged after moving and renaming
Hi,
I'm currently able to upload files to my application, but when I try to open the file I get an error saying the file is damaged. I think the reason is because I rename the file and haven't got the extension right. First, I have an input field in my form where the user can choose a name for the file
$fileName = $request->fileName;
Then I've specified the path to store the file
$path = $buildingID.'/'.$category.'/';
After that I request the file:
$uploadedFile = $request->file('fileInput')->getClientOriginalName();
$fileExtension = $request->file('fileInput')->getClientOriginalExtension();
And then move it and rename it like so:
Storage::disk('dokumentarkiv')->put($path.$uploadedFile, $uploadedFile);
Storage::disk('dokumentarkiv')->move($path.$uploadedFile, $path.$fileName.'.'.$fileExtension);
But I can't figure out what I'm doing wrong. Any help is greatly appreciated!
Please or to participate in this conversation.