Neeraj1005's avatar

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.');
        }
    }
0 likes
11 replies
Neeraj1005's avatar

@michaloravec @sinnbeck

In cpanel I did not found the select php version.

in cpanel under php.ini. I mentioned the fileinfo but it is not working is this correct?

display_errors = Off
max_execution_time = 30
max_input_time = 60
max_input_vars = 1000
memory_limit = 32M
post_max_size = 8M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php73"
upload_max_filesize = 2M
zlib.output_compression = Off
fileinfo = On
Sinnbeck's avatar
Sinnbeck
Best Answer
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.