PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kpraman
Forum Contributor
Posts: 172 Joined: Fri Oct 13, 2006 10:54 am
Post
by kpraman » Fri Dec 15, 2006 8:20 am
Hello,
I am using this code for watermarking images
Code: Select all
echo $imagesource=$_GET['path'];
$filetype = substr($imagesource,strlen($imagesource)-4,4);
$filetype = strtolower($filetype);
if($filetype == ".gif") $image = @imagecreatefromgif($imagesource);
if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource);
if($filetype == ".png") $image = @imagecreatefrompng($imagesource);
if (!$image) die();
$watermark = @imagecreatefrompng('watermark.png');
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = (($imagewidth - $watermarkwidth)/2);
$startheight = (($imageheight - $watermarkheight)/2);
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
imagejpeg($image, "image1/imagepic.jpg");
imagedestroy($image);
imagedestroy($watermark);
i am not able to upload images which are outside the folder.
if i want to use,
Code: Select all
$tmp_name = $_FILES["path"]["tmp_name"];
$name = $_FILES["path"]["name"];
instead of
, what should i do?
Thanx
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Dec 15, 2006 8:28 am
set $imagesource accordingly.
kpraman
Forum Contributor
Posts: 172 Joined: Fri Oct 13, 2006 10:54 am
Post
by kpraman » Fri Dec 15, 2006 8:37 am
i am trying to use the form to post images.
Code: Select all
<form action="" method="post" enctype="multipart/form-data">
<p>Pictures:
<input type="file" name="path" />
<input type="submit" value="Submit">
</p>
</form>
Code: Select all
$tmp_name = $_FILES["path"]["tmp_name"];
$name = $_FILES["path"]["name"];
how do i alter the code so that i can use the above code instead of
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Dec 15, 2006 8:43 am
I already told you, set $imagesource accordingly.
dibyendrah
Forum Contributor
Posts: 491 Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:
Post
by dibyendrah » Fri Dec 15, 2006 11:07 am
Replace
with
Code: Select all
$imagesource = $_FILES["path"]["name"];