Skip to content Skip to sidebar Skip to footer

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:\Users\Tuskar\Desktop\Projekt\htdocs\Project IT-Space\Profile\edit_profile

Solution 1:

You should use form method to POST instead of get.

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

Solution 2:

Make sure your FORM tag has method="POST". GET requests do not support multipart/form-data uploads.

Solution 3:

I hope this works: the form:

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

the php file:

<?phpif($_POST) {
    $max_size = mysql_real_escape_string(strip_tags($_POST['MAX_FILE_SIZE']));
    $file = $_FILES['fupload']['name'];

    if(isset($max_size) && !empty($max_size) && !empty($file)) {
        $file_type = $_FILES['fupload']['type'];
        $tmp = $_FILES['fupload']['tmp_name'];
        $file_size = $_FILES['fupload']['size'];

        $allowed_type = array('image/png', 'image/jpg', 'image/jpeg', 'image/gif');

        if(in_array($file_type, $allowed_type)) {
            if($file_size < $max_size) {
                $path = 'images/'.$file;

                move_uploaded_file($tmp, $path);
                //if you want to store the file in a db use the $path in the query
            } else {
                echo'File size: '.$file_size.' is too big';
            }
        } else {
            echo'File type: '.$file_type.' is not allowed';
        }
    } else {
        echo'There are empty fields';
    }
}
?>

Solution 4:

Upload Picture

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

PHP file

<?phpif (isset( $_POST['submit'] ))
    {
    if (isset($_FILES['fupload'] ))
    {
    echo"name: ".$_FILES['fupload']['name']." <br> ";
    echo"size: ".$_FILES['fupload']['size']." <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) ordie ("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 ";
    }
    ?>

Post a Comment for "Image - Upload Not Responding, No Access To $_files"