Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

php - Image - Upload not responding, no access to $_FILES

Here is my file-upload script, and i am getting the following error

Notice: Undefined index: fupload in C:UsersTuskarDesktopProjekthtdocsProject IT-SpaceProfileedit_profile_parse.php on line 8

But according there should not error, because i identified the index. It seems i don't have access to the $_FILES array, because before i got this error ive been getting other similar errors or the programm completely passes the if and goes directly to the else (file not chosen)

I know the script is primitive and includes almost no security, but i just want it to work first before i add other features like max file size or file restriction ... :(

Here is the code i am using.

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>

Here is the php that handles the form

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 ";
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should use form method to POST instead of get.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...