$ _FILES给出了错误

时间:2013-12-02 22:18:11

标签: php file-upload

    <h1>Upload File</h1>
<form enctype="multipart/form-data" method="post" action="upload.php">
<input type="hidden" name = "MAX_FILE_SIZE" value="100000000000">
<input type ="file" name="userfile">
<input type = "submit" value="Upload File">
</form>

php脚本(upload.php)

<?php
$userfile = $_FILES['userfile']['tmp_name'];
$userfile_name = $_FILES['userfile']['name'];
$userfile_size = $_FILES['userfile']['size'];
$userfile_type = $_FILES['userfile']['type'];
$userfile_error = $_FILES['userfile']['error'];

if($userfile_error>0){
    echo 'Problem : ';
    switch ($userfile_error)
    {
        case 1: echo 'File exceeded upload_max_filesize'; break;
        case 1: echo 'File exceeded max_File_size'; break;
        case 1: echo 'File only partially uploaded'; break;
        case 1: echo 'No file uploaded'; break;

    }
    exit;
}

if ($userfile=='none'){
    echo 'No file uploaded';
    exit;
}

if ($userfile_size==0){
    echo ' Problem : Uploaded file size is zero';
    exit;
}

if ($userfile_type!='text/plain'){
    echo 'File type is not Text format';
    exit;
}

$upfile = '/uploads/'.$userfile;

if (is_uploaded_file($userfile)){
    if(!move_uploaded_file($userfile,$upfile)){
        echo 'Could not move uploaded file';
        exit;
    }
}
else {
    echo 'Possible File Attack';
    exit;
}

echo 'File Uploaded Successfuly<br />';

$fp = fopen($upfile,'r');
$comment = fread ($fp,filesize($upfile));
fclose($fp);

$comment = strip_tags($comment);
$fp = fopen($upfile,'w');
fwrite($fp,$comment);
fclose($fp);

echo ' Preview of uploaded files<br />';
echo $comment;

我在upload.php上遇到此错误    

注意:未定义的索引:第2行的C:\ wamp \ www \ upload.php中的用户文件

  

注意:未定义的索引:第3行的C:\ wamp \ www \ upload.php中的用户文件

   

注意:未定义的索引:第4行的C:\ wamp \ www \ upload.php中的用户文件

  

注意:未定义的索引:第5行的C:\ wamp \ www \ upload.php中的用户文件

 

注意:未定义的索引:第6行的C:\ wamp \ www \ upload.php中的用户文件

0 个答案:

没有答案