I use this script to upload a file to the server using laravel.
$fileName = time().'_'.$request->file->getClientOriginalName();
Storage::put('/public/uploads/'.$fileName,$request->file('file'));
$url = Storage::url('public/uploads/'.$fileName);
$fileModel = new File;
$fileModel->name = time().'_'.$request->file->getClientOriginalName();
$fileModel->file_path = $url;
$fileModel->save();
this code works great in local host (wamp server) but when I use it in the server, get this error: "message": "The "" file does not exist or is not readable.", "exception": "Symfony\Component\Mime\Exception\InvalidArgumentException", I also tried to upload lots of know file types (png,pdf,jpeg,mp4,...). same error
CodePudding user response:
- Check for folder permission issues including the temporary folder on the server
tmp
. - Check the maximum upload file size:
upload_max_filesize
andpost_max_size
in your server settings.