I'm trying to upload a file but it always returns null in my controller. Here's the error I'm getting:
FatalThrowableError in FileController.php line 25:
Fatal error: Call to a member function getClientOriginalExtension() on null
Form
<form enctype="multipart/form-data" method="post" action="">
<label for="file_upload">Upload file</label>
<input id="file_upload" type="file" name="file">
<input type="submit" value="Upload">
</form>
Route (not calling any middleware)
Route::post('file/upload', [
'as' => 'upload',
'uses' => 'FileController@handleUpload',
]);
Controller
public function handleUpload(Request $request)
{
$dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'adp';
if (!file_exists($dir)) mkdir($dir);
$extensions = AppPlatform::lists('package_extension')->toArray();
$extension = $request->file('file')->getClientOriginalExtension(); // this line throws the nullreference exception
...
}
I may have overlooked something very obvious but can't seem to find where the problem lies at the moment.
via Fester