[英]laravel file does not exist or is not readable
I am trying to send zip file in laravel but i receive this error:我正在尝试在 laravel 中发送 zip 文件,但我收到此错误:
When I upload my file it uploads
, also my database get updates
so basically no problem with physical file nor database data the only issue is that i receive this error somehow!当我上传it uploads
的文件时,我的database get updates
,所以物理文件和数据库数据基本上没有问题,唯一的问题是我以某种方式收到这个错误!
Here is my controller code
public function sendCompanyData(Request $request)
{
$this->validate($request, array(
'coDoc' => 'required|mimetypes:application/zip|max:10000',
));
$company = CompanyData::where('user_id', Auth::user()->id)->first();
//file
if ($request->hasFile('coDoc')) {
$coDoc = $request->file('coDoc');
$filename = $company->user->username . '-Company-Prove-Documents-' . str_random(10) . '-' . time() . '.' . $coDoc->getClientOriginalExtension();
$location = public_path('files/idus/');
$request->file('coDoc')->move($location, $filename);
$oldFilename = $company->files;
$company->files = $filename;
if(!empty($company->files)){
Storage::delete($oldFilename);
}
$company->files = $filename;
}
$company->save();
//send confirmation mail
$userMail = $company->user->email;
$data = array(
'id' => $company->id,
'user' => $company->user->username,
'files' => url('files/idus', $company->files),
'submit_time' => $company->created_at->format('d M, Y | H:m:s A'),
);
Mail::to($userMail)->send(new MailToAdmin($data));
return redirect()->back();
}
Any idea?任何想法?
I fix it !我修复它 !
do not use "move" function for save your file不要使用“移动”function 来保存文件
I use Storage::disk('public')->putFileAs and work我使用 Storage::disk('public')->putFileAs 和工作
I think can't move tmp file in laravel version 6!我认为无法在 laravel 版本 6 中移动 tmp 文件!
You need to check if you have an error like: "The file "***.jpg" exceeds your upload_max_filesize ini directive (limit is 2048 KiB)."您需要检查是否有错误,例如:“文件“***.jpg”超出了您的 upload_max_filesize ini 指令(限制为 2048 KiB)。”
like $coDoc->getErrorMessage()
像$coDoc->getErrorMessage()
I think it's a permission error..give 777 on your folder我认为这是一个权限错误..在您的文件夹上输入 777
suDO chmod -R 777 /YOUR_FOLDER
check your php.ini...make sure that your upload_max_filesize is as big as your post_max_size.检查您的 php.ini...确保您的 upload_max_filesize 与您的 post_max_size 一样大。
https://github.com/laravel/framework/issues/31249 https://github.com/laravel/framework/issues/31249
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.