Re: Re: Uploading PDF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
(
    [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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux