Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.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
Laravel NotWritableException可以';t将图像数据写入heroku上的路径_Laravel_Heroku_Laravel 5_Laravel 5.5 - Fatal编程技术网

Laravel NotWritableException可以';t将图像数据写入heroku上的路径

Laravel NotWritableException可以';t将图像数据写入heroku上的路径,laravel,heroku,laravel-5,laravel-5.5,Laravel,Heroku,Laravel 5,Laravel 5.5,我正在尝试将图像数据保存到文件夹中。它在我的本地主机上运行良好,但当我将其移动到heroku时,会出现此错误 NotWritableException Can't write image data to path (https://arcane-peak- 34431.herokuapp.com/public/images/categories/1527155055.jpg) 这是我的密码 $image = $request->file('image'); $imagename

我正在尝试将图像数据保存到文件夹中。它在我的本地主机上运行良好,但当我将其移动到heroku时,会出现此错误

NotWritableException
Can't write image data to path (https://arcane-peak- 
34431.herokuapp.com/public/images/categories/1527155055.jpg)
这是我的密码

$image = $request->file('image');
    $imagename = $image->getClientOriginalExtension();
    $imagename = time().'.'.$imagename;

    $destinationPath = URL::to('public/images/restaurants');
    $img = Image::make($image->getRealPath());

    $img->resize(100, 100, function ($constraint) {
        $constraint->aspectRatio();
    })->save($destinationPath.'/'.$imagename);

    $destinationPath = URL::to('public/images/restaurants');

    $image->move($destinationPath, $imagename);

我做错了什么?此外,在我的本地计算机上,正在保存的是上载的图像,但我希望保存已调整大小的图像。任何帮助都将是一个救命稻草。

更大的问题是,即使您让图像保存,它也会消失。Heroku使用(粗体添加):

每个dyno都有自己的临时文件系统,以及最近部署的代码的新副本。在dyno的生命周期内,其运行进程可以将文件系统用作临时草稿行,但任何其他dyno中的进程都看不到写入的文件,一旦dyno停止或重新启动,写入的任何文件都将被丢弃。例如,由于应用程序部署而更换dyno时,以及作为正常dyno管理的一部分,大约每天一次,都会发生这种情况。


使用第三方服务存储用户上传,如。

您没有回答有关错误的问题。我得到了同样的异常,我知道这是一个短暂的文件系统。这并不能解决问题。你对异常的原因有什么建议吗?