Home > other >  I have an issue in uploading file in laravel, how can I solve this problem?
I have an issue in uploading file in laravel, how can I solve this problem?

Time:10-23

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:

  1. Check for folder permission issues including the temporary folder on the server tmp.
  2. Check the maximum upload file size: upload_max_filesize and post_max_size in your server settings.
  • Related