PHP form to get data from user plus a file upload field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jeniea
Forum Newbie
Posts: 2
Joined: Mon Feb 07, 2005 9:28 am
Contact:

PHP form to get data from user plus a file upload field

Post by jeniea »

I am currently working on a PHP form that will require users to input data but I also need to offer them them the option of attaching a file. Since this form will be emailed I need to check the file size to ensure it is under 5 MB. Has anybody ever created a PHP form that allows a file upload field?

Thanks
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

just create a form with input type of file mulipart/formdata enctype.

then on your action page you can check the file size with:

$_FILES['yourfilename']['size'];

if it meets your criteria, then use move_uploaded_file to move it to the location on the server you want.

there should me a million posts in here about file uploads, try doing a search and I'm sure you'll find what you're looking for.

Burr
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Post Reply