Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 uploading zip file showing Undefined variable: e

I've created a file upload method and the file uploading with the file extension like jpg, png etc are successful. However, when I upload a zip file, it says me "Undefined variable: e". To find, I did dd() at the beginning of the respective method but it still says the above error. My route is as below:

Route::post('media/savedata/{id?}/{page?}', 'Administrator\MedialibraryController@savedata'); 

The method is as below:

public function savedata($id, $page, Request $request) {
 ...
}

The content of the "network" tab is as below:

Request URL: http://localhost/stmd/administrator/media/savedata/0/1
Request Method: POST
Status Code: 500 Internal Server Error
Remote Address: [::1]:80
Referrer Policy: no-referrer-when-downgrade

------WebKitFormBoundaryaHtERzAAThbQB4ae
Content-Disposition: form-data; name="_token"

TXLvBGRXrdjpQbhAjm18MTxkiHamauvcjhKBhl6n
------WebKitFormBoundaryaHtERzAAThbQB4ae
Content-Disposition: form-data; name="fileType"

I
------WebKitFormBoundaryaHtERzAAThbQB4ae
Content-Disposition: form-data; name="fileName"; filename="gradle-3.5-bin.zip"
Content-Type: application/zip

My intention is: If zip file is upload then it will redirect to another page however, I can't do this because even dd() is not working.

UPDATE:

Below is the Laravel Log:

[2018-07-23 11:59:51] local.ERROR: Undefined variable: e {"exception":"[object] (ErrorException(code: 0): Undefined variable: e at /var/www/html/stmd/app/Exceptions/Handler.php:76)
[stacktrace]
#0 /var/www/html/stmd/app/Exceptions/Handler.php(76): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined varia...', '/var/www/html/s...', 76, Array)
#1 /var/www/html/stmd/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(83): App\\Exceptions\\Handler->render(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Exceptions\\PostTooLargeException))
#2 /var/www/html/stmd/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(55): Illuminate\\Routing\\Pipeline->handleException(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Exceptions\\PostTooLargeException))
#3 /var/www/html/stmd/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#4 /var/www/html/stmd/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#5 /var/www/html/stmd/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#6 /var/www/html/stmd/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#7 /var/www/html/stmd/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#8 /var/www/html/stmd/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#9 /var/www/html/stmd/public/index.php(58): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#10 /var/www/html/stmd/index.php(4): include('/var/www/html/s...')
#11 {main}
"} 

My Handler.php content is below:

public function render($request, Exception $exception)
    {
        if($this->isHttpException($exception)){
            $logFile = 'laravel.log';

            Log::useDailyFiles(storage_path().'/logs/'.$logFile);
            //echo Route::getCurrentRoute()->getAction();



            //echo $exception->getStatusCode();exit;
            switch ($exception->getStatusCode()) {

                case 404:
                    Log::info('Unable to find page.');
                    return response()->view('errors.404',[],404);

                    break;

                case 500:

                    Log::error('In Server is really going wrong.');
                    return response()->view('errors.500',[],500);

                    break;
                 default:
                    return $this->renderHttpException($e);
                break;

            }

        }
        return parent::render($request, $exception);
    }
}
like image 556
Niladri Banerjee - Uttarpara Avatar asked Jul 23 '18 11:07

Niladri Banerjee - Uttarpara


1 Answers

Change

return $this->renderHttpException($e);

to

return $this->renderHttpException($exception);

in

app/Exceptions/Handler.php

like image 177
Quezler Avatar answered Nov 14 '22 18:11

Quezler