Hi there,
I am creating a form where users fill in fields in order to add products to a database. The issue now is I want them to be able to browse their hard drive and select an image to upload to the server. The image can be placed in a directory but I want to be able to overwrite images that exist in that folder on the server. I need it simple for the user to be able to upload.
Any ideas?
Is it possible to upload an image to a server via form?
Moderator: General Moderators
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
http://ee.php.net/features.file-upload
yup php definatly supports file uploads and whatnot. read that and it even gives you a same code to use to upload the file then, like i said before, use getimagesize to verify that is a file so someone doesnt try pulling a fast one on you and uploading a file that is called virus.exe.jpg. getimagesize would return false on that but a file extension grabber would return true.
yup php definatly supports file uploads and whatnot. read that and it even gives you a same code to use to upload the file then, like i said before, use getimagesize to verify that is a file so someone doesnt try pulling a fast one on you and uploading a file that is called virus.exe.jpg. getimagesize would return false on that but a file extension grabber would return true.
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
Ok I seem to have got it but I have a user concern I am wondering about. The form has many fields and by adding this upload feature to it, it makes that part of the error checking now. If the user messes up another part of the form, it gives an error and they will have to re-select each image (there are 3). I am worried about it getting a bit annoying for the user if they make an error on another part of the form and have to re-select all the images.
Any ideas on that?
Any ideas on that?
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
you could at the top of the processing page set the 3 pathes to the files to seperate session variables ie
then if it messes up (ie the user chooses a incorrect file) you can use
do that for all 3 and i guess that would work. thats completly untested but i assume it would work.
Code: Select all
$_SESSION[file_a] = //whatever;
$_SESSION[file_b] = //whatever;
$_SESSION[file_c] = //whatever;Code: Select all
<input name="e;userfile"e; type="e;file"e; value="e;<? echo $_SESSIONїfile_a]; ?>"e;>Nope, onion is right...can't do it.
you could check to make sure the form isn't "messed" up on the client side with JS and then it would keep the file info an just tell them to fix what's "messed" up.
those who dont' have JS enabled would suffer, but tough for them for not catching up to the 21st century.
you could check to make sure the form isn't "messed" up on the client side with JS and then it would keep the file info an just tell them to fix what's "messed" up.
those who dont' have JS enabled would suffer, but tough for them for not catching up to the 21st century.