Very small assistance please

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hello I have a small script that Im trying to upload files onto a
Linux Webserver
but it fails the move_uploaded_file()  w/o giving an error or any hint
as to why. My hosting plan only allows Premium members (which I dont
have) to view error logs so I can not check them either. If anyone
might have a small clue why its failing please let me know.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://">
<html xmlns=" ">
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Untitled Document</title>

// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used
// of $_FILES.

$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
    echo "File is valid, and was successfully uploaded.\n";
    if (move_uploaded_file($_FILES['userfile']['name'],$uploadfile)) {
        echo "File has been moved successfully.\n";
    }else {
        echo "Problem moving the file.\n";
} else {
    echo "Possible file upload attack!\n";

echo 'Here is some more debugging info:';

print "</pre>";
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="form.php" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
    <!-- Name of input element determines name in $_FILES array -->
    Send this file: <input name="userfile" type="file" />
    <input type="submit" value="Send File" />


Re: Very small assistance please


Looks like you have a typo. Should be:

move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)

You can also add error_reporting(E_ALL) to the top of your script to
see any other potential notices.


John Peters

Quoted text here. Click to load it

Re: Very small assistance please

Quoted text here. Click to load it

How to put this............ DOH!
Thanks for pointing that out. I need to improve my seeing what is
there instead of what I want to be there skills.

Site Timeline