【发布时间】:2021-04-12 11:16:58
【问题描述】:
我正在尝试通过在 Laravel 7 上使用 getimagesize() php helper 来获取确切的上传图像大小。但我收到了一个错误
ErrorException: Undefined property: Illuminate\Http\UploadedFile::$name 在代码所在的行:
if($request->file('image') != null){
$upload = $request->file('image');
$sourceProperties = getimagesize($upload->name);
请帮助理解这些问题,因为它只发生在 Debian 服务器上而不是本地...它在本地工作正常
【问题讨论】:
-
试试这个
$request->file('image')->getSize(); -
@sta 这给了我一个 int 而不是数组中的图像大小信息,例如:array:7 [ 0 => 474 1 => 172 2 => 2 3 => "width=" 474" height="172"" "bits" => 8 "channels" => 3 "mime" => "image/jpeg" ];这样我就可以分别得到宽度和高度
标签: php laravel file-upload