getimagezise Error pasing filename

Posted by Talha Bin Shakir on Stack Overflow See other posts from Stack Overflow or by Talha Bin Shakir
Published on 2009-11-22T06:40:57Z Indexed on 2010/03/14 6:05 UTC
Read the original article Hit count: 218

Filed under:

Hi, 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.

© Stack Overflow or respective owner

Related posts about php