File Upload Problem with Thumbnails

This is a discussion on File Upload Problem with Thumbnails within the PHP Language forums, part of the PHP Programming Forums category; I have a very simple file upload script which creates a thumbnail of the file (jpg) upon uploading. This works ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2007
callieandmark@yahoo.co.uk
 
Posts: n/a
Default File Upload Problem with Thumbnails

I have a very simple file upload script which creates a thumbnail of
the file (jpg) upon uploading. This works fine with small images,
however, if i try to upload a file over about 1mb the thumbnail
dosen't show. Any ideas ?
Thanks for any advice.

Reply With Quote
  #2 (permalink)  
Old 03-26-2007
Mike Roetgers
 
Posts: n/a
Default Re: File Upload Problem with Thumbnails

callieandmark@yahoo.co.uk schrieb:
> I have a very simple file upload script which creates a thumbnail of
> the file (jpg) upon uploading. This works fine with small images,
> however, if i try to upload a file over about 1mb the thumbnail
> dosen't show. Any ideas ?
> Thanks for any advice.
>

Maybe post_max_size is set to 1M in your php.ini?
Reply With Quote
  #3 (permalink)  
Old 03-26-2007
callieandmark@yahoo.co.uk
 
Posts: n/a
Default Re: File Upload Problem with Thumbnails

No, the post_max is set at 8M
Thanks

Reply With Quote
  #4 (permalink)  
Old 03-26-2007
shimmyshack
 
Posts: n/a
Default Re: File Upload Problem with Thumbnails

On 26 Mar, 15:06, "callieandm...@yahoo.co.uk"
<callieandm...@yahoo.co.uk> wrote:
> No, the post_max is set at 8M
> Thanks


advice is to post your code for better answers.
Do you use exif data to create the thumb, perhaps the larger jpgs
don't have that info, etc.. just guesses at this point.

Reply With Quote
  #5 (permalink)  
Old 03-26-2007
delishus
 
Posts: n/a
Default Re: File Upload Problem with Thumbnails

On Mar 26, 5:53 am, "callieandm...@yahoo.co.uk"
<callieandm...@yahoo.co.uk> wrote:
> I have a very simple file upload script which creates a thumbnail of
> the file (jpg) upon uploading. This works fine with small images,
> however, if i try to upload a file over about 1mb the thumbnail
> dosen't show. Any ideas ?
> Thanks for any advice.


You also need to check the size of your upload_max_filesize in the
php.ini - if your post_max is 8M, then your upload_max is probably
only 2M.

Reply With Quote
  #6 (permalink)  
Old 03-26-2007
callieandmark@yahoo.co.uk
 
Posts: n/a
Default Re: File Upload Problem with Thumbnails

The upload max is 20M.
If i try to upload a large file (over 1mb) it uploads fine, its just
that the thumbnail is not created.

The code is :
$tsize = "300"; //thumbnails size (pixel)
$path = "uploads/"; //image path, where the images should be
uploaded to
$tpath = "thumbs/"; //your thumbnails path
$name="$uploaded_file_name";
$imgf = "$uploaded_file_name";
$thbf = $tpath.$imgf;
function createthumb($name,$filename,$new_w,$new_h){
$system=explode('.',$name);
if (preg_match('/jpg|jpeg|JPG/',$system[1])){
$src_img=imagecreatefromjpeg($name);
}
if (preg_match('/png|PNG/',$system[1])){
$src_img=imagecreatefrompng($name);
}
if (preg_match('/gif|GIF/',$system[1])){
$src_img=imagecreatefromgif($name);
}

$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}

$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thum b_w,$thumb_h,$old_x,
$old_y);


if (preg_match("/png/",$system[1]))
{
imagepng($dst_img,$filename);
}
if (preg_match("/gif/",$system[1]))
{
imagegif($dst_img,$filename);
}
else {
imagejpeg($dst_img,$filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}


createthumb($path.$imgf,$tpath.$imgf,$tsize,$tsize );


Reply With Quote
  #7 (permalink)  
Old 03-26-2007
Willem Bogaerts
 
Posts: n/a
Default Re: File Upload Problem with Thumbnails

> I have a very simple file upload script which creates a thumbnail of
> the file (jpg) upon uploading. This works fine with small images,
> however, if i try to upload a file over about 1mb the thumbnail
> dosen't show. Any ideas ?
> Thanks for any advice.


Does the full jpg gets uploaded properly? In that case, it is not in the
upload settings.

I guess that you use the gd image functions. In that case, note that a
jpg is a compressed image. To work with it, it must be uncompressed. If
you want to resample it, you'd probably have both the original and the
target uncompressed in memory at some point. If you configure PHP to use
only a limited amount of memory, that memory may be too little, even if
the uploaded file is not that big. Does increasing the memory limit help?

Best regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Reply With Quote
  #8 (permalink)  
Old 03-26-2007
shimmyshack
 
Posts: n/a
Default Re: File Upload Problem with Thumbnails

On 26 Mar, 15:48, Willem Bogaerts
<w.bogae...@kratz.maardanzonderditstuk.nl> wrote:
> > I have a very simple file upload script which creates a thumbnail of
> > the file (jpg) upon uploading. This works fine with small images,
> > however, if i try to upload a file over about 1mb the thumbnail
> > dosen't show. Any ideas ?
> > Thanks for any advice.

>
> Does the full jpg gets uploaded properly? In that case, it is not in the
> upload settings.
>
> I guess that you use the gd image functions. In that case, note that a
> jpg is a compressed image. To work with it, it must be uncompressed. If
> you want to resample it, you'd probably have both the original and the
> target uncompressed in memory at some point. If you configure PHP to use
> only a limited amount of memory, that memory may be too little, even if
> the uploaded file is not that big. Does increasing the memory limit help?
>
> Best regards,
> --
> Willem Bogaerts
>
> Application smith
> Kratz B.V.http://www.kratz.nl/


uploads are slow, i think this is a max execution problem time
problem, as you script works fine and fast for 2-3MB files, tested on
15MB file - /then/ the memory was high, but otherwise pretty small.
2*1024^2 / 30 is about 500kbits/s which is kinda what you expect the
wrong end of ADSL to be - the upper limit for us poor UK'rs

Reply With Quote
  #9 (permalink)  
Old 03-26-2007
shimmyshack
 
Posts: n/a
Default Re: File Upload Problem with Thumbnails

On 26 Mar, 15:48, Willem Bogaerts
<w.bogae...@kratz.maardanzonderditstuk.nl> wrote:
> > I have a very simple file upload script which creates a thumbnail of
> > the file (jpg) upon uploading. This works fine with small images,
> > however, if i try to upload a file over about 1mb the thumbnail
> > dosen't show. Any ideas ?
> > Thanks for any advice.

>
> Does the full jpg gets uploaded properly? In that case, it is not in the
> upload settings.
>
> I guess that you use the gd image functions. In that case, note that a
> jpg is a compressed image. To work with it, it must be uncompressed. If
> you want to resample it, you'd probably have both the original and the
> target uncompressed in memory at some point. If you configure PHP to use
> only a limited amount of memory, that memory may be too little, even if
> the uploaded file is not that big. Does increasing the memory limit help?
>
> Best regards,
> --
> Willem Bogaerts
>
> Application smith
> Kratz B.V.http://www.kratz.nl/


well of course 2*8*1024^2/30 !

Reply With Quote
  #10 (permalink)  
Old 03-26-2007
callieandmark@yahoo.co.uk
 
Posts: n/a
Default Re: File Upload Problem with Thumbnails

Mx execution time is set at 50000 which i believe is a pretty long
time ?

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:22 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0