简体   繁体   English

laravel 文件不存在或不可读

[英]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 文件,但我收到此错误:

一

Issue问题

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 ,所以物理文件和数据库数据基本上没有问题,唯一的问题是我以某种方式收到这个错误!

Code代码

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.

相关问题 laravel 文件上传 - "" 文件不存在或不可读 - laravel file upload - The "" file does not exist or is not readable laravel 文件上传会引发错误“文件不存在或不可读”。 - laravel file upload throws an error “file does not exist or is not readable.” "message": "关键路径 \\"file:///app/storage/oauth-private.key\\" 在 Laravel 6 中不存在或不可读" - "message": "Key path \"file:///app/storage/oauth-private.key\" does not exist or is not readable" in Laravel 6 无法上传 Laravel 中的图像:““C:\xampp\tmp\php38A9.tmp“文件不存在或不可读。” - Unable to upload image in Laravel: “The ”C:\xampp\tmp\php38A9.tmp“ file does not exist or is not readable.” 如何解决此 Laravel 问题 - “/tmp/phpY14gRo”文件不存在或不可读? - How to resolve this Laravel issue - The “/tmp/phpY14gRo” file does not exist or is not readable? Laravel生产:文件“ /home/forge/default/storage/app/geoip.mmdb”不存在或不可读 - Laravel production: The file “/home/forge/default/storage/app/geoip.mmdb” does not exist or is not readable 当图像已上传到文件夹中时,如何解决 laravel 中的“文件不存在或不可读” - how to solve “file does not exist or is not readable” in laravel while the image have been uploaded in folder Heroku“ oauth-private.key”不存在或不可读-Laravel 5 - Heroku “oauth-private.key” does not exist or is not readable - Laravel 5 oauth-private.key 在 Laravel 中不存在或不可读 - oauth-private.key does not exist or is not readable in laravel 文件在Laravel中不可读 - File not readable in Laravel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM