getimagesize:无法打开流错误

时间:2014-12-23 01:48:23

标签: php

上传图片时出现错误消息

Warning: getimagesize(C:\xampp\tmp\phpA563.tmp): failed to open stream: No such file or directory in C:\xampp\htdocs\dzmarket\admin\controllers\c_banners.php on line 61

我的代码是

        $file = $_FILES['image'];
        $allowedExt = array('jpg', 'jpeg', 'png');
        $uploadsDirectory = 'resources/uploads/banners/';
        $maxSize = 4000000;
        $upload = new Upload($file, $allowedExt, $uploadsDirectory, $maxSize);
        $uploadFile = $upload->uploadFiles();
        $fileNames = $upload->getFilesName();
        $tmpname = $file['tmp_name'][0];
        $fileSize = getimagesize($tmpname);

并且print_r($ file)给了我

Array ( [name] => Array ( [0] => 623211835.jpg ) [type] => Array ( [0] => image/jpeg ) [tmp_name] => Array ( [0] => C:\xampp\tmp\php9584.tmp ) [error] => Array ( [0] => 0 ) [size] => Array ( [0] => 605275 ) )

我正确调用了tmp_name,但我不知道问题在哪里

1 个答案:

答案 0 :(得分:0)

在上传文件之前调用getimagesize()。对我来说,上传文件后删除了$ _FILES ['图片'] [' tmp_name']。