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,

--
Steve M.

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

Reply via email to