Re: Re: Uploading PDF
| From: | Aleksandar Vojnovic | Date: | Fri, 15 Feb 2008 08:18:16 +0000 |
| Subject: | Re: Re: Uploading PDF | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269358@lists.php.net to get a copy of this message | ||
Upload error 2 occurs when the file size exceeds the maximum allowed upload size.
Aleksander
David Robley wrote:
Pastor Steve wrote:Greetings, I am getting an error when I am trying to upload a PDF file through a script. When I do a print_r($_FILES) I get the following: Array (The error number tells you what is happening - check the values at http://php.net/manual/en/features.file-upload.errors.php Essentially, the file is bigger than the MAX_FILE_SIZE directive that was specified in the HTML form Cheers[userfile] => Array ( [name] => document.pdf [type] => [tmp_name] => [error] => 2 [size] => 0 )) Docs and html will both upload. Anybody have an idea why? Here is the script that I am using: <?php // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead // of $_FILES. $uploaddir = '../cms/documents/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {$filename = $_FILES['userfile']['name']; echo "<b>File is valid, and was successfully uploaded.</b>\n <br />Select and copy the link below to reference this file.<p /> <pre><a href=\"documents/$filename\">$filename</a></pre><p/><b>WARNING:</b> This link will not be available anywhere else. "; } else { echo "Possible file upload attack!\n";} echo '<pre>'; echo 'Here is some more debugging info:'; print_r($_FILES); print "</pre>"; ?> Thanks,