11

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
  • If you solved your problem please answer your own question so that it doesn't appear as "unanswered" anymore and serves as a future reference for others. Commented May 3, 2014 at 13:59

4 Answers 4

33

In the php.ini file, change the following:

upload_max_filesize = 20M
post_max_size = 20M

This should make it work.

Sign up to request clarification or add additional context in comments.

2 Comments

It would be best to leave a comment saying that this answer is taken from OP, rather than putting this note in the post itself (as we try to keep the noise out of posts). And most people would probably recommend making the post Community Wiki.
This is the best answer as I was stuck and could not find the actual reason and this did solve my issue
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());
}
//...

Comments

2

In 2020 with Laravel 5.8, I discovered this problem and your answers gave me clues, but I was still getting an error when I tried the isValid method. I found this was the best way to check if a file was too large:

    $file_result = new \stdClass();
    if ($request->file('file_to_upload')->getSize() === false) {
        $max_upload = min(ini_get('post_max_size'), ini_get('upload_max_filesize'));
       //From: https://gist.github.com/svizion/2343619
        $max_upload = str_replace('M', '', $max_upload);
        $max_upload = $max_upload * 1024;
        $file_result->error = "The file you are trying to upload is too large. The maximum size is " . $max_upload;
        //return whatever json_encoded data your client-side app expects.
    }

It looks as if the getSize method successfully returns false if the file size exceeds the maximum size. In my experience isValid throws an obscure error. The upload_max_filesize parameter is there to protect the server so I wanted a reliable way of catching when the user attempts to upload a large file and my client-side validation is not set correctly.

Comments

0

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

1 Comment

This was addressed in 2014 + The accepted answer states the changes to be made in the php.ini file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.