pdoak's avatar
Level 1

FileNotFoundException in Filesystem.php line 36:

I have been using the same code for a couple of years but today I have run into a problem. When I try and upload a pdf, I get the error:

FileNotFoundException in Filesystem.php line 36:

public function store(CreateFilesRequest $request)
{
    $files = Request::file('filefield');
    $file_count = count($files);
    $uploadcount = 0;
    foreach ($files as $file) {
        // $upload = Request::all();
        $upload = new Files($request->all());

        // start count how many uploaded

        $clientID = "";
        $dcmid = "";
        $account = "";
        if ($upload['file_category'] == 'statement') {
            $name = $file->getClientOriginalName();
            list($name_init, $clientID, $initial, $account,$pdf_date) = explode('_', $name);
            $len = strlen($account);
            $dcmid = substr($account,0,$len-2);

        }
        // return $clientID;

        $extension = $file->getClientOriginalExtension();
        Storage::disk('local')->put($file->getFilename().'.'.$extension,  File::get($file));
        $upload->mime = $file->getClientMimeType();
        $upload->original_filename = $file->getClientOriginalName();
        $upload->filename = $file->getFilename().'.'.$extension;
        // dd(Auth::user()->id);
        $upload->user_id = Auth::user()->id;
        $upload->clientID = $clientID;
        $upload->dcmid = $dcmid;
        $upload->accountNo = $account;
        $upload->save();

        $uploadcount ++;

    }

    if($uploadcount == $file_count){
        flash()->success('Successfully uploaded '.$uploadcount. ' files');

        return redirect('uploads');
    }
    else {
        return Redirect::to('uploads')->withInput()->withErrors($validator);
    }
}
0 likes
6 replies
Snapey's avatar

FileNotFound exception should say at path...

Can you include the top 10 lines from the stack trace

Is it the size of the file that is causing the issue?

Do you have enough free disk space?

pdoak's avatar
Level 1

Thanks for your help.

The file that I am trying to upload is 8Mb and I have 13Gb of free space available. I have also checked the php.ini and have the following setting:

upload_max_filesize = 20M

The first 10 lines of the stack trace are:

FileNotFoundException in Filesystem.php line 36:
File does not exist at path


in Filesystem.php line 36
at Filesystem->get(object(UploadedFile)) in Facade.php line 210
at Facade::__callStatic('get', array(object(UploadedFile))) in FilesController.php line 222
at File::get(object(UploadedFile)) in FilesController.php line 222
at FilesController->store(object(CreateFilesRequest))
at call_user_func_array(array(object(FilesController), 'store'), array(object(CreateFilesRequest))) in Controller.php line 246
at Controller->callAction('store', array(object(CreateFilesRequest))) in ControllerDispatcher.php line 162
at ControllerDispatcher->call(object(FilesController), object(Route), 'store') in ControllerDispatcher.php line 107
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
pdoak's avatar
Level 1

Thanks Snapey.

My php.ini file is in /etc/php5/fpm and has the following settings:

post_max_size = 20M
upload_max_filesize = 20M

Is there anything else I counld try.

Many Thanks

Paul

pdoak's avatar
Level 1

I think that I have found the problem. My php.ini file has these settings:

post_max_size = 20M
upload_max_filesize = 20M

But if I run phpinfo(), it shows the settings as:

upload_max_filesize 2M
post_max_size   8M

I am running an nginx server and have restarted the server after changing the settings in the php.ini file using:

sudo nginx service restart

pdoak's avatar
Level 1

I solved the problem.

sudo nginx service restart does not restart the php service. You also have to:

sudo restart php5-fpm

Please or to participate in this conversation.