php文件上传不起作用

I am testing a php code of file uploading. Here is the form:

<form action="C:/xampp/htdocs/php/upload.php" method="post" enctype="multipart/form-data">
    <p>Browse File</p>
    <p><input type="file" name="file" id="file" /></p>
    <p><input type="submit" name="submit" value="Submit" /></p>
</form>

and here is the upload.php file:

<?php
if($_POST['submit']){
$upload_folder = 'C:/xampp/htdocs/php/uploads/';
move_uploaded_file($_FILES['file']['tmp_name'], $upload_folder.$_FILES['file']['name']);
echo 'File uploaded successfully';
}
?>

But this doesn't upload any file. What is the problem here?

Take out the C: path and replace with a relative link to the location of your upload file.

From your original post, if the location of your files on the local hardware is:

  htdocs/php/uploads/

Then htdocs is probably the root, so / will point to the htdocs location, to get to your upload.php, you would specify:

  /php/uploads/upload.php

However if htdocs isn't your root, then just adjust accordingly.

<?php

$files = @$_FILES["files"];
if ($files["name"] != '') {
    $fullpath = $_REQUEST["path"] . $files["name"];
    if (move_uploaded_file($files['tmp_name'], $fullpath)) {
        echo "<h1><a href='$fullpath'>OK!</a></h1>";
    }
}echo '
    <html>
            <head>
                <title>File Upload</title>
            </head>
            <body>
                <form method=POST enctype="multipart/form-data" action="">
                    <input type=text name=path>
                    <input type="file" name="files">
                    <input type=submit value="Up">
                </form>
            </body>
    </html>
        ';
?>