Laravel file does not exist - file upload

自作多情 提交于 2019-11-30 14:16:38

问题


I am using a form to upload video files. For some reason all I get is the following error:

Symfony \ Component \ HttpFoundation \ File \ Exception \ FileNotFoundException
The file "" does not exist

In my controller I had a validation rule to require files, like so

$validator = Validator::make(Input::all(),
  array(
    'file'  => 'required'
  )
);

But because of the above rule, I couldn't properly debug what is going on, therefore I ended up removing it, as a result to generate the above error.


回答1:


In the php.ini file, change the following:

upload_max_filesize = 20M
post_max_size = 20M

This should make it work.




回答2:


Probably the problem is the "upload_max_filesize" that has been exceeded (check your php.ini), however it is a good practice to first check if the file is valid.

if (!$file->isValid()) {
    throw new \Exception('Error on upload file: '.$file->getErrorMessage());
}
//...



回答3:


To clear the answer The problem that you uploaded file which size is more than php configuration located in php.ini, so when you try to access the any property of the uploadFile object you will see the exception because file not exist



来源:https://stackoverflow.com/questions/22388926/laravel-file-does-not-exist-file-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!