Page 1 of 1

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

Posted: Wed Feb 23, 2005 10:28 am
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

Posted: Wed Feb 23, 2005 11:01 am
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

Posted: Thu Feb 24, 2005 3:09 am
by CoderGoblin