SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2012
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    resizing multiple images from form

    Hello,

    I would appreciate if someone could help me. I have created a form to upload information on cars (taxis).
    I would like to introduce a classified page onto my website which is meant to inform taxi drivers around my
    city what is going on around our trade.

    I would like to allow visitors to my site to fill the form below with details of their taxis they want to sell but I
    have few problems.
    1. Firstly, I do not know how to resize multiple images into two different sizes. That is, I want each photo to
    be resized (1. maximum width of 150), (2. maximum width of 600).

    2. The files should be named uniquely and then saved in a file named "image".

    3. I would like visitors the option to load or not load images, but if they do load, how do I ensure they load
    images and nothing else.

    I would be grateful if someone can write me a code. thank you.

    <table>
    <form name = "taxiforsaleform" action = "taxiforsalephp.php" method = "post" enctype = "multipart/form-data">
    <tr>
    <td>Brand/td><td><input type = "text" name = "brand"></td>
    </tr>
    <tr>
    <td>Model/td><td><input type = "text" name = "model"></td>
    </tr>
    <tr>
    <td>Year of Registration/td><td><input type = "text" name = "reg"></td>
    </tr>
    <tr>
    <td>Photo 1</td><td><input type = "file" name = "photo1"></td>
    </tr>
    <tr>
    <td>Photo 2/td><td><input type = "file" name = "photo2"></td>
    </tr>
    <tr>
    <td>Photo 3/td><td><input type = "file" name = "photo3"></td>
    </tr>
    <tr>
    <td>Contact No/td><td><input type = "text" name = "contactno"></td>
    </tr>
    <tr>
    <td colspan = "2"><input type = "submit" name = "submit" value = "Submit"</td>
    </tr>
    </form>
    </table>

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    I would be grateful if someone can write me a code.
    I am afraid you have come to the wrong place for that; we will help with any code you have. How else will you learn?

    Have a go first and post back when you have tried - there are lots of tutorials for uploading multiple images on the web.

    You also need to think about how you link the image to the text - are you using a database?

    You are asking for an upload/resize code and some code to display the adverts; quite a bit of work

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    Sounds like you need to find a content management system if you don't want to build one yourself. Anything from Joomla to Drupal to WordPress could probably accomplish what your asking with the right add-ons with very little programming on your behalf.
    The only code I hate more than my own is everyone else's.

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Location
    The Netherlands
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Name your file inputs in your form photo[], they will be submitted as an array then and you can easily loop through them.
    Next thing is checking if the images are real images. Looking at the extension won't be enough.
    install gd library if it isn't already.
    When images pass the image check you have to find the height and width of the image and calculate the resizing.
    Then do the actual resizing. And save both files to disk with a unique name. You can first save the larger image, resize it to smaller version and save smaller file in map thumbs, or add thumb to the name. Also you could reserve a database entry and use the primary key as image name. Look around on the www, much information can be found.


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
  •