944,028 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1325
  • PHP RSS
Jul 5th, 2006
0

upload files hlp

Expand Post »
i've put in this thres before and didnt get much hlp.
i wanna enable users of the site to upload a picture into a file (like in hi5 or yahoo messenger) and have it displayed as a thumbnail which would have a link to the original sized picture.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
quansah is offline Offline
10 posts
since Aug 2005
Jul 5th, 2006
0

Re: upload files hlp

I use the similar on my store2go site. You can do it in two ways:
1. Upload image and instantly create a thumbnail. See code:
[php]
// if jpg use
$src_img=ImageCreateFromJpeg($uploadedfile);
// else if gif use
$src_img=ImageCreateFromGif($uploadedfile);
// and for png use
$src_img=ImageCreateFromPng($uploadedfile);

// create the scaled instance for thumbnail in GIF
$dst_img=imagecreatetruecolor($thumb_width,$thumb_height);
ImageCopyResampled($dst_img,$src_img,0,0,0,0,$thumb_width,$thumb_height,$mywidth,$myheight);
// write the damned thing to disk
ImageGif($dst_img,"uploaddir/thumbnail.gif");

[/php]
2. Upload image and resize to the acceptable resolution (say 800x600 max). When displaying the thumb and link, simply resize the resized image using code below:
[php]
$size = GetImageSize($image);
$width = round($size[0]);
$height = round($size[1]);
$percentage = 1;
// set target thumbnail size
$targetw = 100;
$targeth = 75;

// reduce image to target dimensions
if ($width > $height) {
if ($width > $targetw) $percentage = ($targetw / $width);
}
else {
if ($height > $targeth) $percentage = ($targeth / $height);
}
$width = round($width * $percentage);
$height = round($height * $percentage);
echo '<a href="'.$image.'"><img src="'.$image.'" border="0" alt="" width="'.$width.'" height="'.$height.'"></a>';
[/php]
Reputation Points: 10
Solved Threads: 7
Posting Whiz in Training
zippee is offline Offline
294 posts
since Jan 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Help With Messages in Mysql Stop Overwriting
Next Thread in PHP Forum Timeline: about shopping center





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC