araumaker Posted August 23, 2006 Posted August 23, 2006 Hello out there, I have a form for users that asks them to upload photo. GIF files can be uploaded but it won't allow JPG files to be uploaded. I've already tried varying the file size to see if that was issue and that's not it. Could it be that form posts to database? Any suggestions?? I used the php form generator from Fantastico. AR Quote
TCH-Bruce Posted August 23, 2006 Posted August 23, 2006 What file types are you testing for and allowing to be uploaded? You should also be making sure that files like .exe and .zip cannot be uploaded. Quote
araumaker Posted August 23, 2006 Author Posted August 23, 2006 What file types are you testing for and allowing to be uploaded? You should also be making sure that files like .exe and .zip cannot be uploaded. I am new to php and mysql. I only want image files to be uploaded so yes I will need to add for exe and zip. Currently it's just files so I could see if it worked. Right now I've just been trying to upload any image files. Now I was actually able to upload a jpg image so I looked at size. The image was only 5kb so now I am thinking it is a file size issue. My question now would be how do I know if I am making the value in the database column Length/Values large enough for aa photo? I was thinking in terms of kbs when I set it 2024. At 20000 I still can't upload images of 23kb. Is there a formula or something? Quote
Steve Scrimpshire Posted August 24, 2006 Posted August 24, 2006 I forget my byte to kilobyte math, but isn't 20000 less than 23kb? My understanding is that 1 kb == 1024 bytes. Therefore 23 kb == 23552 and 20000 bytes == 19.53 kb which would explain why a 23 kb image can't be uploaded when the limit is 20000. Also remember that if you convert a jpeg to gif format, it gets greatly reduced in size in the conversion, so a 23 kb jpeg becomes a much smaller gif. I created my own upload.html form and upload.php to process uploading png files if you are interested in seeing them: This is upload.html: ><html> <body> <form enctype="multipart/form-data" action="upload.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="2200000" /> <!-- Name of input element determines name in $_FILES array --> PNG Image to Convert: <input name="image" type="file" /> <input type="submit" value="Send File" /> </form> </body> </html> Here is upload.php I think my script is pretty secure and of course you can change png to jpg in your case. If you need help in doing that, I can try to help. Quote
araumaker Posted August 24, 2006 Author Posted August 24, 2006 thank you. the form is workign with the changes in value size, just need to add some limits in terms of file types thanks again Quote
carbonize Posted September 11, 2006 Posted September 11, 2006 As stated above you can specify a file size limit in the actual HTML. Once the file is uploaded you can get it's size and mime type before moving it from the tmp folder this way you can be sure it's an image and within the file size limits. www.tizag.com/phpT/fileupload.php is a good basic tutorial and http://us2.php.net/features.file-upload explains more about what you can get using the $_FILES array. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.