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
PHP form to get data from user plus a file upload field
Moderator: General Moderators
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
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
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany