1

I have the below PHP script processing my form.

Why am I not seeing the file in the specified location?

Is there something I am doing wrong with regards to the file's location?

<html>
<head>
    <title>Upload</title>
</head>
<body>
    <form enctype="multipart/form-data" action="uploadFile.php" method="post">
        <input type="file" name="file" id="file">
        <br>
        <input type="submit">
    </form>
</body>

<?php

    echo "Processing...<br>";

    $fileResult = "";
    if($_FILES["file"]["error"] > 0)
    {
        $fileResult .= "No File Uploaded";
        $fileResult .= "Error Code: " + $_FILES["file"]["error"];
    } else
    {
        $fileResult .= 
        "Upload:" . $_FILES["file"]["name"] . "<br>" .
        "Type:" . $_FILES["file"]["type"] . "<br>" . 
        "Size:" . $_FILES["file"]["size"] . "<br>" .
        "Temp File:" . $_FILES["file"]["tmp_name"] . "<br>";

        move_uploaded_file($_FILES["file"]["tmp_name"], "/home6/schne.../public_html/FileStore/Data/". $_FILES["file"]["name"]);


        $fileResult .= "File Uploaded";
    }

    echo $fileResult;


?>
4

1 回答 1

0

If the problem isn't server-side, there's two places to easily go wrong.

You may have forgotten then enctype attribute in your form. Your upload form should look like this:

<form method='post' enctype='multipart/form-data'>

Also, make sure you have a MAX_FILE_SIZE submitted in the $_POST array:

<input type='hidden' name='MAX_FILE_SIZE' value='100000' />
于 2013-07-10T00:17:44.657 回答