getimagesize() 在尝试获取 public 文件夹图像的尺寸时不输出任何结果

getimagesize() doesn't output any result when trying to get dimensions of a public folder images

我的 laravel 项目中有 8000 多张图片,其中大部分图片的类型不同。所以我想做的是通过 getimagesize() 检查图像的尺寸,但是当我在 laravel 控制器中使用这个函数时,它不会输出任何东西。请参考我试过的代码。当我 dd() 图像 url 它工作但是当我将 url 传递给函数时它只是超过了执行时间并且没有任何反应。但是,如果我将不同的 url 传递给该方法(几乎是托管的东西),它会输出我想要的结果。我已经完成了下面的问题,是的,我觉得图像的路径有问题。所以谁能帮我解决这个问题。

    <?php

namespace App\Http\Controllers;

use App\Product;
use function asset ;
use Illuminate\Http\Request;
use ParagonIE\Sodium\File;

class testingController extends Controller
{
   public function testing (){

       //fetching all the products from the DB
       $products = Product::all();

       //looping the products and generating image path
      foreach ($products as $product) {

        //image path
        $img = asset ( 'uploads/products_thumbnails').'/'.$product->thumbnail_file_name;

      //  dd($img); //this is working

        //http://localhost:8000/products/1234568.jpg

        $check = getimagesize ( $img);

        dd($check); //this dosen't output anything

        // if ( File::exists($img)){

        // }
      }
   }
}

但是如果我尝试下面的操作

  $check = getimagesize ( 'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png');

    dd($check); 

   array:6 [▼
  0 => 272
  1 => 92
  2 => 3
  3 => "width="272" height="92""
  "bits" => 8
  "mime" => "image/png"
]

请注意,我几乎已经完成了以下问题。

PHP getimagesize() not working

如何在 Laravel Framework 中获取图像的宽度和高度?

这个函数有问题

$img = asset ( 'uploads/products_thumbnails').'/'.$product->thumbnail_file_name;

尝试在没有资产功能的情况下访问您的 public 文件夹。

$img = 'uploads/products_thumbnails/'.$product->thumbnail_file_name;