一尘不染

图片-上传无响应,无法访问$ _FILES

mysql

这是我的文件上传脚本,出现以下错误

Notice: Undefined index: fupload in C:\Users\Tuskar\Desktop\Projekt\htdocs\Project IT-Space\Profile\edit_profile_parse.php on line 8

但是据此应该不会出错,因为我确定了索引。看来我无权访问$
_FILES数组,因为在收到此错误IVE之前,我一直遇到其他类似的错误,或者程序完全通过了if并直接进入else(未选择文件)

我知道该脚本是原始脚本,几乎不包含安全性,但是我只想让它先工作,然后再添加其他功能,例如最大文件大小或文件限制… :(

这是我正在使用的代码。

Upload Picture
<form action="edit_profile_parse.php" method="get" enctype="multipart/form-data" >
<input type="hidden" name="MAX_FILE_SIZE" value="999999999"> </input>
<input type="file" name="fupload"> </input>
<input type="submit" name="submit" value="Upload"> </input>
</form>

这是处理表格的PHP

if (isset( $_GET['submit'] ))
{
if (isset($_FILES['fupload'] ))
{
echo "name: ".$_FILES['fupload']['name']." <br> ";
echo "size: ".$_FILES['fupload']['sizw']." <br> ";
echo "type: ".$_FILES['fupload']['type']." <br> ";

    if ($_FILES['fupload']['type'] == "image/gif")
    {
        $source = $_FILES['fupload']['tmp_name'];
        $target = "images/" .$_FILES['fupload']['name'];
        move_uploaded_file($source, $target) or die ("Error: " .mysql_error());
        $size = getImageSize($target);

        $imgstr = "<img src=\" '".$target."' \">";
        echo $imgstr;
    }
    else
    {
    echo "Problem uploading the file ... ";
    }
}   
else
{
echo "No file chosen !! ";
}
}
else
{
echo "Button not clicked ";
}

阅读 395

收藏
2020-05-17

共1个答案

一尘不染

您应该使用表单方法来发布而不是获取。

<form action="edit_profile_parse.php" method="post" enctype="multipart/form-data" >
2020-05-17