Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

You should use form method to POST instead of get.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...