Uploading images

I’m trying to figure out the best way to do this.
I want to create a html form where the user can upload images, then those images would be emailed to me and id be able to accept/delete them (depending if they are appropriate) If I accept it, the image would be renamed, re sized or croped if needed. But if the image was declined, it would simply be moved to another directory.
Is there a good utility out that there that would do this or should I use PHP?

Thanks…

the best way!.. there is none… but there are good practices and yes php would work perfect for this simple task. For a small task like this i would just build a few functions to handle the form input validation and then a function to handle the file validation (“make sure it’s an image and allowed img type”) After that i would have a few functions to handle the email sides of things such as making sure important data is set and then another function to build the email and another to send the email.

the reason i would use so many functions or even classes to build this is separation of code is awesome for later additions and you really can stick to the KISS(“keep it simple stupid”) principle so you and other people can understand your code.

PHP can do this easily for you and there are plenty of examples of uploading files on the www.

Make sure you check the mime type of uploaded image file to make sure it is not a malicious executable instead of an image. Don’t just check the file name extension.

Basically, when you run move_uploaded_file() in your form processing script to move the uploading image to a staging directory, use php’s mail() function to send you an email of the uploaded image’s path if move_uploaded_file() returned true.

If the image is appropriate, then you can use various php functions to move/rename the image file to an appropriate directory and then update/add any relevant database records if required.