473,386 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.

Mar 26 '07 #1
11 1638
ca***********@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?
Mar 26 '07 #2
No, the post_max is set at 8M
Thanks

Mar 26 '07 #3
On 26 Mar, 15:06, "callieandm...@yahoo.co.uk"
<callieandm...@yahoo.co.ukwrote:
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.

Mar 26 '07 #4
On Mar 26, 5:53 am, "callieandm...@yahoo.co.uk"
<callieandm...@yahoo.co.ukwrote:
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.

Mar 26 '07 #5
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 );
Mar 26 '07 #6
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/
Mar 26 '07 #7
On 26 Mar, 15:48, Willem Bogaerts
<w.bogae...@kratz.maardanzonderditstuk.nlwrote:
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

Mar 26 '07 #8
On 26 Mar, 15:48, Willem Bogaerts
<w.bogae...@kratz.maardanzonderditstuk.nlwrote:
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 !

Mar 26 '07 #9
Mx execution time is set at 50000 which i believe is a pretty long
time ?

Mar 26 '07 #10
Oh, and memory limit is 40M
Mar 26 '07 #11
On 26 Mar, 17:04, "callieandm...@yahoo.co.uk"
<callieandm...@yahoo.co.ukwrote:
Mx execution time is set at 50000 which i believe is a pretty long
time ?
yes it is!! Hmmm a mystery!
Have you checked the bug database for your version, Im using latest
php as module in the latest apache version, there are known bugs for
all kinds of functions, if you problem were at around the 2MB mark I
would have one in mind from a case I looked at in php4 for instance.

All we have done so far is check the process script, which I am
assuming you have run independently of the upload script, as you have
verified the upload as working with large files.

What OS are you on, you could trace the HDD activity with filemon if
on windows, that often shows up good stuff.

I do note that the way you grab the filename assumes things about them
- only one period - which I assume is because you are in total control
of their names when uploaded.

Mar 26 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike | last post by:
Sites using thumbnail preview for world wide web file navigation and searching. Below are list of sites that are either researching or providing thumbnail preview images for online web...
6
by: jonathanmcdougall | last post by:
I have read many posts on this subject and found no satisfying answer. I am creating a file on the server via a PHP script. The file is created using GD (imagejpeg()), though I don't think it is...
1
by: Øyvind Isaksen | last post by:
Hello! I need a fileuploader that automatic make thumbnails in different sizes when an image is uploaded to the server (ASP/Win2003). Does anyone have experience with this, something to...
1
by: Will | last post by:
I've got a file upload happening to upload an image file to the server. During this process I want to also create a thumbnail of the image in the same directory, and adjust the size of the image...
2
by: Duane Phillips | last post by:
On image upload, I would like to save the image and also auto-create a right-size image for faster browsing, and also a thumbnail for indexes, so that slower connections do not have to wait for the...
8
by: ctiggerf | last post by:
I was hopeing someone could help me out here. Been stumped on this one all day. This function 1. Checks uploaded files. 2. Creates two resized images from each (a full size, and a...
6
Markus
by: Markus | last post by:
I'm adding to my script a section that allows a thumbnail to be created and saved. I get this error: Warning: imagejpeg() : Unable to open '../uploads/thumb/' for writing: Is a directory in...
8
johngault
by: johngault | last post by:
I've been working with this PHP page for several days now and I'm stumped. The page is supposed to allow the user to upload up to six images for their profile. When the user adds an image it (the...
4
by: samatair | last post by:
Hi I have being working on a form. The form allows 5 image files to be uploaded with other user details. All the 5 image files are uploaded at the same time (with a single submit button click)....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.