Re: Uploading PDF

From: Date: Fri, 15 Feb 2008 01:44:18 +0000
Subject: Re: Uploading PDF
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-269346@lists.php.net to get a copy of this message
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 > ( > [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>&lt;a > href=\"documents/$filename\"&gt;$filename&lt;/a&gt;</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, > 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 -- David Robley Couldn't myself have better it said. Today is Sweetmorn, the 46th day of Chaos in the YOLD 3174.

« previous php.general (#269346) next »