我有这个数组想要获取图像的大小:$main_image = $product->images()->where('main_image', 1)->first();if($main_image){ $url = asset('uploads/products/'. $main_image['image']); $image[] = [ "name" => $main_image->image, "type" => FileUploader::mime_content_type($main_image->image_path), "size" => filesize($url), "file" => $main_image->image_path, "local" => $main_image->image_path, ];}我得到这个错误:filesize(): stat failed for http://myapp.test/uploads/products/83QhiRFarGpV.jpeg 甚至我的图像也存在于文件夹中!我尝试了这个中的所有选项,但仍然有相同的错误!
1 回答
哈士奇WWW
TA贡献1799条经验 获得超6个赞
您的代码用于生成 :asset()
$url
http://myapp.test/uploads/products/83QhiRFarGpV.jpeg
该函数适用于本地文件,而不是 URL。filesize()
filesize($main_image->image_path)
应该可以工作,因为您正在上面的行中使用它来获取文件类型。
您可能还遇到了另一个问题
"file" => $main_image->image_path, "local" => $main_image->image_path,
您可能希望文件所在的位置。$url
- 1 回答
- 0 关注
- 76 浏览
添加回答
举报
0/150
提交
取消