我在 Laravel 应用程序中尝试使用 Laravel Excel 导入 Excel 文件时遇到问题。我使用以下代码上传和导入文件:
public function import_excel(Request $request)
{
try {
$this->validate($request, [
'file' => 'required|mimes:xls,xlsx'
]);
} catch (\Illuminate\Validation\ValidationException $e) {
return redirect()->back()->withErrors($e->validator->errors())->withInput();
}
// capturing the excel file
$file = $request->file('file');
// creating a unique file name
$nama_file = rand().$file->getClientOriginalName();
$file->move('file_member', $nama_file);
// importing data
Excel::import(new MemberImport, public_path('/file_member/' . $nama_file));
// notifying through session
$message = [
"status" => $file ? "success" : "failed",
"message" => $file ? "Member Data Successfully Imported" : "Failed to Import Member Data!"
];
// redirecting back
return redirect()->route('index.member.registration')->with("message", $message);
}
但是,在生产环境中尝试导入文件时,遇到了错误 “找不到 zip 成员 zip:///home/u1572391/public_html/koperasi-app/storage/framework/cache/laravel-excel/laravel-excel-wVFjYv63g1d69UTbCrnD9xb7WAc37Hse.xlsx#_rels.rels,”
表示在 zip 文件中查找特定成员时出现问题。任何人都可以提供有关如何处理此错误的指导或建议吗?生产环境中是否还需要进行任何额外的配置或步骤?
当我尝试在本地站点上导入时,一切顺利,但当我在在线服务器上尝试时,出现错误
此错误表示无法读取 xlsx 文件
如果您想要更准确的答案,可以提供您的xlsx文件
最有可能的两个罪魁祸首是:
app/storage/framework/cache/laravel-excel/laravel-excel-wVFjYv63g1d69UTbCrnD9xb7WAc37Hse.xlsx