Hey I need a script that will: 1. Allow the user to upload 1 image only 2. accept gif, jpeg, png and bmp 3. convert the gif/jpeg/png/bmp to .jpg 4. resize the image automatically 4. automatically save the file in a specified folder automatically renaming the file e.g. to photo.jpg (and will overwrite that file if another is uploaded) Does anyone know of such a script? or can someone make one for me? Thanks guys
This is the best documentation on this subject Tells you everything you asked and more http://ca3.php.net/features.file-upload
last bit of help? I have this: <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], "upload/photo.jpg")) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } ?> PHP: Which works great, and you can upload jpg, gif, png etc... But i cant get them to resize on upload I just need to define height of 156px on upload, anyone any ideas? Maybe (hopefully) just a line of added code? Thanks!
I found this http://blazonry.com/scripting/upload-size.php I never saw or used this function beforem, system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$newfile"); check out the downloads and stuff on the page, seems really good for what you want. hope this helps
GD does it for you. imagecopyresampled() and a bit of maths to scale images correctly or you can use one of the many examples at http://phpclasses.org