简体   繁体   中英

Laravel 5.2 uploading file Unable to write in directory

I'm uploading files in my system and it works locally where am using windows and xampp but when hosting where am using an Linux my file is not being uploaded. I'm getting an error that it cannot be written in the 'system' directory which is within the public folder. This is my code:

$destinationPath = 'uploadFiles/'.$input['infolder']; // upload path
$extension = Input::file('file')->getClientOriginalExtension(); // getting file extension
$fileName = $input['type'] .'_'.sprintf("%06d",$input['id']) .'_'. date("Y-m-d_H-i-s") . '.' . $extension; // renameing image
$upload_success =  Input::file('file')->move($destinationPath, $fileName); // uploading file to given path

在此处输入图片说明

I had a similar problem and solved it by changing the destination path to an absolute rather than relative address. Try using:

$destinationPath = public_path('uploadFiles/'.$input['infolder']);

In a more standard case, the notation would be something like:

$path = public_path('images/' . $filename);

Otherwise, it could be a permissions problem as suggested in the comments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM