Image Uploading getting error , i have a two days not understand how to solve this , I try everything but not working, For help Thanks in Advance
Call to a member function getClientOriginalExtension() on string
$test = $request->file('fileToUpload')->getClientOriginalExtension();
echo $test; die('test');
can you dump your $request and show us the output?
Make sure your upload form has files="true" or multipart header.
View
<?php
echo Form::open(array('url' => '/admin.employment_main','files'=>'true'));
echo 'Select the file to upload.';
echo Form::file('fileToUpload');
echo Form::submit('Upload File');
echo Form::close();
?>
Controller
public function uploadfile(Request $request)
{
$contract = EmployeeContract::create(request()->except(['_method', '_token']));
if ($request->hasFile('fileToUpload'))
{
echo "string";
} else {
echo "no";
}
die();
if (request()->hasFile('fileToUpload')) {
$document->addMediaFromRequest('fileToUpload')->withCustomProperties(['is_default' => true])->employment_enrolment('documents');
}
// alert()->success('Document saved')->autoclose();
}
$request->hasFile('fileToUpload') here was getting the error
Call to a member function hasFile() on string
Why there is a dot in your url? Also true without single quotes. Try this
{{Form::open(array('url' => 'admin/employment_main', 'method' => 'post', 'files' => true))}}
Please or to participate in this conversation.