Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将上载图像保存在公用/存储的post文件夹中_Php_Laravel - Fatal编程技术网

Php 如何将上载图像保存在公用/存储的post文件夹中

Php 如何将上载图像保存在公用/存储的post文件夹中,php,laravel,Php,Laravel,我正试图将上传的图像保存到public\u html/storage/post/。但现在这段代码对我不起作用,并上传到directpublic\uhtml/ $image = $request->file('image'); $slug = str_slug($request->title); if(isset($image)) { // make unipue name for image

我正试图将上传的图像保存到
public\u html/storage/post/
。但现在这段代码对我不起作用,并上传到
directpublic\uhtml/

 $image = $request->file('image');
        $slug = str_slug($request->title);
        if(isset($image))
        {
//            make unipue name for image
            $currentDate = Carbon::now()->toDateString();
            $imageName  = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();

            if(!Storage::disk('public')->exists('post'))
            {
                Storage::disk('public')->makeDirectory('post');
            }

            $postImage = Image::make($image)->save($imageName);
            Storage::disk('public')->put('post/'.$imageName,$postImage);

        } else {
            $imageName = "default.png";
        }

已修复
config/filesystems.php
public root中的问题
'root'=>public_path()。/../public_html/storage',

问题已在
config/filesystems.php
public root中修复
'root'=>public_path()。/../public_html/storage',

你做过php artisan存储:链接吗?是的,我做过存储:链接你做过php artisan存储:链接吗?是的,我做过存储:链接