首页 > 解决方案 > 无法在服务器上将 public_path 设置为 public_html

问题描述

我想在图像上添加一些文本......我已经有一个图像并在其上添加文本......所以现在我正在使用图像干预包。它在我的本地机器上工作正常,但在服务器上它显示一些图像源也没有可读错误....我在上传此代码时看到...图像文本在公共文件夹中工作正常,但我想在 public_html/images 上添加图像而不是 public/images 因为主要图像文件夹位于 public_html 中,所以我可能必须将默认公共路径 public 更改为 public_html。

图像制作功能

   {
 $img = Image::make(public_path('/home/u944619310/domains/shubhampackers.com/public_html/images/Capture.JPG'));  
$img->text('This is a example ', 300, 300);  
$img->save(public_path('/home/u944619310/domains/shubhampackers.com/public_html/images/vivk.jpg'));  
return response()->json(['success'=>true]);
}  



error showing 

message: "Image source not readable", exception: "Intervention\Image\Exception\NotReadableException",…}
exception: "Intervention\Image\Exception\NotReadableException"
file: "/home/u944619310/domains/shubhampackers.com/public_html/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php"
line: 346
message: "Image source not readable"


even i tried given method from stack overflow to do some changes in App/Providers/AppServiceProvider.php

public function register()
   {
       //
      $this->app->bind('path.public', function() {
       return base_path().'/public_html';
   });
   }

标签: laravelimagepackageintervention

解决方案


推荐阅读