The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Uploading images
Discuss Uploading images in the PHP Development forum on Dev Shed. Uploading images PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 22nd, 2012, 11:00 AM
|
|
Contributing User
|
|
Join Date: Aug 2012
Posts: 35
Time spent in forums: 8 h 57 m 13 sec
Reputation Power: 1
|
|
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
|

November 22nd, 2012, 11:40 AM
|
 |
Contributing User
|
|
Join Date: Sep 2002
Location: Seattle, U.S.A.
Posts: 712
 
Time spent in forums: 4 Days 11 h 4 m 59 sec
Reputation Power: 11
|
|
Quote: | 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+...ore+in+database
|

November 22nd, 2012, 11:45 AM
|
|
Contributing User
|
|
Join Date: Aug 2012
Posts: 35
Time spent in forums: 8 h 57 m 13 sec
Reputation Power: 1
|
|
Quote: | Originally Posted by msteudel |
I knew that was gonna come!
thanks anyway
|

November 22nd, 2012, 11:47 AM
|
 |
Contributing User
|
|
Join Date: Sep 2002
Location: Seattle, U.S.A.
Posts: 712
 
Time spent in forums: 4 Days 11 h 4 m 59 sec
Reputation Power: 11
|
|
Quote: | 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!
|

November 22nd, 2012, 11:48 AM
|
 |
Contributing User
|
|
Join Date: Sep 2002
Location: Seattle, U.S.A.
Posts: 712
 
Time spent in forums: 4 Days 11 h 4 m 59 sec
Reputation Power: 11
|
|
|
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.
|

November 22nd, 2012, 01:19 PM
|
|
Contributing User
|
|
Join Date: Aug 2012
Posts: 35
Time spent in forums: 8 h 57 m 13 sec
Reputation Power: 1
|
|
Quote: | 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???
|

November 22nd, 2012, 04:43 PM
|
 |
Contributing User
|
|
Join Date: Sep 2002
Location: Seattle, U.S.A.
Posts: 712
 
Time spent in forums: 4 Days 11 h 4 m 59 sec
Reputation Power: 11
|
|
Quote: | 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.
|

November 22nd, 2012, 05:02 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
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 .
|

November 26th, 2012, 05:35 PM
|
|
Contributing User
|
|
Join Date: Aug 2012
Posts: 35
Time spent in forums: 8 h 57 m 13 sec
Reputation Power: 1
|
|
Quote: | 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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|