#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    35
    Rep Power
    2

    Question Uploading images


    hey guys,

    Im making a car website, that allows the user to log in online and enter vehicles he is trying to sell. This website is meant for one to three users(by one user i mean one-3 people that can actually log in). I have successfully set up the part where the user can add vehicles, and its information. This all works with mysql. Now, im stuck at the part where the user can upload images with the car. I am completely lost. I have read that you can do either upload images to mysql or upload them to your website folder. I dont know how either of those versions work. Please can anyone help me. I need a way for the user to upload images with a vehicle entered. I am completely lost....

    Please any help is accepted,
    thanks
    xxPIRANHAxx
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    12
    Originally Posted by xxPIRANHAxx
    hey guys,

    Im making a car website, that allows the user to log in online and enter vehicles he is trying to sell. This website is meant for one to three users(by one user i mean one-3 people that can actually log in). I have successfully set up the part where the user can add vehicles, and its information. This all works with mysql. Now, im stuck at the part where the user can upload images with the car. I am completely lost. I have read that you can do either upload images to mysql or upload them to your website folder. I dont know how either of those versions work. Please can anyone help me. I need a way for the user to upload images with a vehicle entered. I am completely lost....

    Please any help is accepted,
    thanks
    xxPIRANHAxx
    This should help you out:

    http://lmgtfy.com/?q=php+mysql+how+t...re+in+database
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    35
    Rep Power
    2
    Originally Posted by msteudel
    I knew that was gonna come!

    thanks anyway
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    12
    Originally Posted by xxPIRANHAxx
    I knew that was gonna come!
    So why didn't you do it first?! There are sooo many great tutorials out there that you can literally copy and paste their code into your application. Anyway check those out and then if you run into any specific problems come back and ask. Good luck!
  8. #5
  9. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    12
    Oh and I would probably NOT upload images into the db. I don't think it's necessary and it cause your db to get really bloated.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    35
    Rep Power
    2
    Originally Posted by msteudel
    Oh and I would probably NOT upload images into the db. I don't think it's necessary and it cause your db to get really bloated.
    Then what other ways are there???
  12. #7
  13. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    12
    Originally Posted by xxPIRANHAxx
    Then what other ways are there???
    Just upload the image to the filessystem and then save the image location to the database. Go through those tutorials you'll probably find half a dozen showing you exactly what to do.
  14. #8
  15. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1045
    Hi,

    well, msteudel is of course right that this is standard stuff for which you can find tutorials everywhere.

    However, since you asked about different methods, and since making the file upload secure isn't quite that trivial:

    The standard solution is to simply put the files in the file system of the server. I guess you've already figured out how to put a <input type="file"> in the form and set the right method and enctype attribute of the form? In the target script, all information about the uploaded files will be available in the $_FILES array. The actual files are saved in a temporary directory. You can then move them with move_uploaded_file() to the right directory.

    But you must be very careful with what and how you let users upload files to your server. For example, you certainly don't want people to upload and execute their own PHP scripts.

    So make sure the uploaded file has a specific extension ("jp(e)g", "gif", "png") and check if it's actually an image with getimagesize(). Google for "php secure file upload" for further security considerations .
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    35
    Rep Power
    2
    Originally Posted by Jacques1
    Hi,

    well, msteudel is of course right that this is standard stuff for which you can find tutorials everywhere.

    However, since you asked about different methods, and since making the file upload secure isn't quite that trivial:

    The standard solution is to simply put the files in the file system of the server. I guess you've already figured out how to put a <input type="file"> in the form and set the right method and enctype attribute of the form? In the target script, all information about the uploaded files will be available in the $_FILES array. The actual files are saved in a temporary directory. You can then move them with move_uploaded_file() to the right directory.

    But you must be very careful with what and how you let users upload files to your server. For example, you certainly don't want people to upload and execute their own PHP scripts.

    So make sure the uploaded file has a specific extension ("jp(e)g", "gif", "png") and check if it's actually an image with getimagesize(). Google for "php secure file upload" for further security considerations .
    Sorry I havent responded...
    I hope to try the upload to folder one this weekend as I will have more time to invest then. I will post more...
    thanks for all the help for now thanks

IMN logo majestic logo threadwatch logo seochat tools logo