Php getimagezise复制文件名时出错

Php getimagezise复制文件名时出错,php,Php,我正在使用getimagesize()获取图像的大小。当我将文件名传递给子目录时,我的子目录中有图像,我遇到错误: 没有这样的文件或目录 这是我的密码: <?PHP function resize($img,$max_w){ $max_h=$max_w; list($img_w,$img_h) = getimagesize($img); $f = min($max_w/$img_w, $max_h/$img_h, 1);

我正在使用getimagesize()获取图像的大小。当我将文件名传递给子目录时,我的子目录中有图像,我遇到错误:

没有这样的文件或目录

这是我的密码:

<?PHP
        function resize($img,$max_w){
        $max_h=$max_w;
        list($img_w,$img_h) = getimagesize($img);
        $f = min($max_w/$img_w, $max_h/$img_h, 1);
        $w = round($f * $img_w);
        $h = round($f * $img_h); 
        return array($w,$h);
}

$filename="user_img/"."1256115556.jpg";
$resize=resize($filename,667);
$w=$resize[0];
$h=$resize[1];
?>

从我的主目录文件的功能正在完美运行。因此,请帮助我,如何通过子目录传递文件。

如果您在windows框中,那么您可以尝试在路径中使用“\”而不是“/”。

在getimagesize()中传递目录名。因为文件名是字符串

list($img_w,$img_h) = getimagesize("user_img/".$img);

现在工作正常。

没有,我先尝试过,但是“\”变成了U,整个图片名变成了用户\U imgU1256115556.jpg。添加
echo realpath($filename)到脚本的末尾,并发布输出。检查文件是否确实存在。
list($img_w,$img_h) = getimagesize("user_img/".$img);