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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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? |
|
|||
|
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. |
|
|||
|
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. |
|
|||
|
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 ); |
|
|||
|
> 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/ |
|
|||
|
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 |
|
|||
|
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 ! |