file_exists(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s):

1.2k views Asked by At

I have used barryvdh/laravel-dompdf Laravel package for importing Excel file but I am getting the mentioned error in the attached screenshot.

enter image description here Controller to save an excel file:

    if ($request->hasFile('upload_mcq_file') and in_array($request->upload_mcq_file->extension(), array('xlsx', 'xlt', 'xltx', 'xls', 'xls', 'csv'))) {
        $image = $request->upload_mcq_file;
        $fileName = time() . '.' . $image->getClientOriginalName();
        $image->move('admin/mcqs/', $fileName);
        $path = 'admin/mcqs/' . $fileName;
    }
    $data = Excel::import(new MCQPaperImport, $path);

MCQPaperImport Class below:

class MCQPaperImport implements ToModel
{
    public function model(array $row)
    {
        return new MCQPaper([
            'product_id' => request('product_id'),
            'product_type' => request('product_type'),
            'question' => $row[0],
            'answer' => $row[1],
            'option1' => $row[2],
            'option2' => $row[3],
            'option3' => $row[4],
            'option4' => $row[5],
            'mark' => $row[6],
            'created_at' => Carbon::now('Asia/Kolkata'),
            'updated_at' => Carbon::now('Asia/Kolkata'),
        ]);
    }
}

![Table schema is mentioned in this image][Table schema is mentioned in this image]

0

There are 0 answers