SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,582
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    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...
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •