Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problem displaying resized images
Old 06-13-2006, 09:37 AM Problem displaying resized images
Super Talker

Posts: 145
Trades: 0
Hello everyone,

I have a very strange problem with uploading and resizing images.
I have developed an e-commerce website that the customers can buy online cloths.I have also created an administrator panel for the admin to insert items in the database uploading also their image. The image of the item will be displayed in three different sizes in the e-commerce site, the enlarge,large and small. The image that the user uploads has the dimension width:310 and from that width I use to make the dimensions of the large and small image.

The code that I am using to upload the image is the following:

PHP Code:
<? //copy the image to the server named enlarge_name of image

copy($_FILES['image']['tmp_name'],"../enlarge_"$_FILES['image']['name']);

?>

<? //make the image large
echo  $_POST['txt'];

$uploadedfile $_FILES['image']['tmp_name'];
$src imagecreatefromjpeg($uploadedfile);
list(
$width,$height)=getimagesize($uploadedfile);
$newwidth=$width 0.35 ;  
$newheight=$height 0.35


$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename "../large_"$_FILES['image']['name'];
imagejpeg($tmp,$filename,100);

imagedestroy($src);
imagedestroy($tmp);

?>


<? //make the image small

echo  $_POST['txt'];
$uploadedfile $_FILES['image']['tmp_name'];
$src imagecreatefromjpeg($uploadedfile);
list(
$width,$height)=getimagesize($uploadedfile);
$newwidth=36;  
$newheight=40


$tmp=imagecreatetruecolor($newwidth,$newheight);//small
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);//small
$filename "../small_"$_FILES['image']['name'];//small
imagejpeg($tmp,$filename,100);//small

imagedestroy($src);
imagedestroy($tmp);
?>
The problem I get is that in some images that I upload it displays a black square instead of the image.
The strange thing is that some times the same image might display it and the next time it will not.
As I can understand it uploads them in the server but cannot display them correctly.

I have search everywhere and I did a lot of testing to find the problem but I haven't yet ,so I would be very greatful if you could help me.

Thank you ,
Xenia
xenia is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Problem displaying resized images
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16896 seconds with 12 queries