I am using getimagesize() to get teh size of my image. I have image in my sub-directory when i am passing file name with sub-directory i ma facing an error:
There开发者_高级运维 is no such file or directory
here is my Code:
<?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];
?>
instead of this when i passing
$filename="1256115556.jpg";
file from my main directory the function is running perfectly. So please help me, How to pass file with sub-directory.
Pass your directory name inside getimagesize(). Because the file name is a String.
list($img_w,$img_h) = getimagesize("user_img/".$img);
Its working fine now.
If you're on a windows box then you might try a "\" and not a "/" in your path.
精彩评论