php - file_exists():open_basedir 限制生效。文件 (/tmp) 不在允许的路径内:
问题描述
我已经使用barryvdh/laravel- dompdf Laravel 包来导入 Excel 文件,但在随附的屏幕截图中出现了上述错误。
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 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'),
]);
}
}
解决方案
推荐阅读
- c - 取消引用指向不完整类型“结构名称”的指针
- azure-functions - Azure Function - 应用服务计划 - 安装 git 包
- date - Conditional formatting with date in formula
- docker - Rocket Chat docker-compose.yml not validating
- google-apps-script - 更新谷歌脚本以清除特定范围的单元格
- python - 如何在 CAD 绘图中找到有界区域的数量?
- variables - 会话变量作为标识符
- javascript - 链接 href 不适用于使用 ajax 返回的链接
- android - 更改模拟器上的位置后位置不更新(Google Maps API)
- javascript - 无论用户输入如何,我的输出始终是数组中的第一项