Reputation: 193
I tried uploading a file with the following code in ubuntu
$file = $request->file('file_upload');
$destination = app_path() . '/myStorage/';
$fileName = $sampleName . '-' . date('Y-m-d-H:i:s') . '.' . $file->getClientOriginalExtension();
$file->move($destination, $fileName);
and it worked fine. Now i am trying to run the same code in Windows OS and i am getting the following error
Could not move the file "C:\wamp64\tmp\php6570.tmp" to "C:\wamp64\www\gittest\gittest\IBA\app\myStorage\Test-2016-02-17-10:43:27.xlsx" ()
Is there any problem in the code or is there a permission issue? Please help me.
Upvotes: 1
Views: 686
Reputation: 12845
The filename contains ':' which are not allowed on windows in file names. That is the reason probably you are getting the error.
Try
$filename = $sampleName . '-' . date('Y-m-d-H_i_s') . '.' . $file->getClientOriginalExtension();
Should be able to save the file then.
Basically replace the ':' (colon) in the date(format) with any thing which is allowed as filename on windows. Even a space would be ok like:
$filename = $sampleName . '-' .date('Y-m-d H i s') . '.' . $file->getClientOriginalExtension();
Or
$filename = $sampleName . '-'.date('Y-m-d g i A').'.' . $file->getClientOriginalExtension(); //ex output Test-2016-02-18 11 25 AM.xls
Upvotes: 1