HTML Form Upload PDF with other form contents using PHP

Posted by Sev on Stack Overflow See other posts from Stack Overflow or by Sev
Published on 2010-03-31T21:55:18Z Indexed on 2010/03/31 22:33 UTC
Read the original article Hit count: 352

Filed under:
|

I have a HTML form with fields such as name, address, notes, etc. I also have a field to upload a PDF. The uploaded PDF get's stored on the file system.

How can I accomplish this if possibly the PDF files are larger than 2 MBs? Also, for some reason, the uploading of the PDF (< 2 MBs) works fine in Chrome, but not in IE. In IE, the upload doesn't even begin, but in Chrome, it completes fine.

Form header looks like:

method='post' ENCTYPE='multipart/formdata'

edit: the ini setting didn't help

The HTML

<input type='text' name='user' />
<input type='file' name='userfile' />

The basic PHP ( I do some preg matching above, that I haven't included)

$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "File uploading failed.\n";
}

© Stack Overflow or respective owner

Related posts about php

Related posts about form-upload