0

I have asked this question before I made changes to my code and my image upload is not working at all I have checked username password, and Root they are all correct. my code will not show any errors I dont know what to do anymore can someone please help me? I have changed my connection for security reasons

<?php 

$con = mysqli_connect("localhost", "torcdesi_jone45", "password", "torcdesi_amazing");
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$query_image = 'INSERT INTO shirt_table (images3) 
                values( "' . $_FILES['file3']['name'] . '")';
?>
<?php

include("configur.php");
if($_POST) { 
    // $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.

     if ($_FILES["file3"]["error"] > 0) {
        // if there is error in file uploading 
        echo "Return Code: " . $_FILES["file3"]["error"] . "<br />";
    } else {
        // check if file already exit in "images" folder.
        if (file_exists("shirtimgs/" . $_FILES["file3"]["name"])) {
        } else { 
            //move_uploaded_file function will upload your image. 
            if(move_uploaded_file($_FILES["file3"]["tmp_name"],"shirtimgs/" . $_FILES["file3"]["name"]))
            {
                // If file has uploaded successfully, store its name in data base
                $query_image = "insert into shirt_table";

                if(mysqli_query($link, $query_image)) {
                    echo "Stored in: " . "shirtimgs/" . $_FILES["file3"]["name"];
                } else {   
                    echo'';
                }
            }
        }
    }
 }
 ?>
11

1 Answer 1

2

As I stated in comments, your form is missing a proper enctype to handle files.

This I know, since I saw your other question that did not contain it in the form.

<form enctype="multipart/form-data" action="__URL__" method="POST">

As per the manual:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.