Do you have enabled fileinfo extension in php.ini?
Aug 7, 2020
11
Level 9
Call to undefined function PhpOffice\PhpSpreadsheet\Reader\mime_content_type()
what is reason for this error? can anyone give me a suggestion? This is my controller code
public function importData(Request $request)
{
$uid = Auth::user()->id;
// echo json_encode($request->input());
$filename = '';
if ($request->hasfile('importFile')) {
//-------------Image Validation----------------------------------
$file = $request->file('importFile');
// Build the input for validation
$fileArray = array('importFile' => $file, 'extension' => strtolower($file->getClientOriginalExtension()));
// Tell the validator that this file should be an image
$rules = array(
'importFile' => 'required', // max 10000kb
'extension' => 'required|in:csv'
);
// Now pass the input and rules into the validator
$validator = Validator::make($fileArray, $rules);
// Check to see if validation fails or passes
if ($validator->fails()) {
return redirect('/accounts/import/csv')->with('error', 'Please upload .csv only.');
}
//-------------Image Validation----------------------------------
$name = time() . '.' . $file->getClientOriginalExtension(); //getClientOriginalName()
$path = $request->file('importFile')->getRealPath();
$res = Excel::import(new AccountsImport($uid), request()->file('importFile'));
if ($res) {
echo 'Success';
return redirect('/accounts')->with('success', 'Uploaded successfully');
} else {
// echo 'Failed';
return redirect('/accounts/import/csv')->with('error', "Error ocurred. Try again later..!");
}
} else {
return redirect('/accounts/import/csv')->with('error', 'Please upload file.');
}
}
Level 102
If it is a hosted service, you could try contacting your provider and ask them to turn it on for you
1 like
Please or to participate in this conversation.