Can't find image in GD (PHP) -
i'm trying put watermark on images, script can't find watermark image. i'm doing dynamically, each user there watermark in watermarks folder. when trying use code:
session_start(); $username = $_session['_user_login']; // set path image watermark $input_image = $targetpath.$newname; // read in text watermark image $watermark = imagecreatefrompng("../watermarks/$username.png");
nothing happens. tried printing user name variable , works fine. tried print image , works also. when using imagecreatefrompng, watermark image never found. looking in log see following error:
warning: imagecreatefrompng(../watermarks/.png) [function.imagecreatefrompng]: failed open stream: no such file or directory
i don't it. doing wrong?
thanks.
you need use:
$watermark = imagecreatefrompng(dirname(dirname(__file__)) . "/watermarks/" . $username . ".png");
(you can print dirname(__file__)
check directory structure before using method).
Comments
Post a Comment