I want to upload images to my database, these can be done using php and mysqli . The form contains some information like file descriptiopn and input file and when i submit the file the file will automatically enters in to the database and the image will be stored in a directoy (my default directory uploads). After SUbmit i can edit and delete the information and images in the db and the changes keep saved.

Please help me thanq

Recommended Answers

All 8 Replies

Please help me thanq

Any specific issue, or are you just looking for a ready-made script?

ready-made script or a tutorial to do that

i want this to learn also can someone provide links for this so i can also study the code :)

Add record – Insert sql query
List record - Select sql query
Edit record - update sql query
Delete record - delete sql query
w3schools.com is the best site to learn these things.

ready-made script or a tutorial to do that

Could be a nice one for our tutorial section though.

Hi i am uploading images to a folder and also the path to database can anyone please tell me how to fetch those images and text from the database.

<?php
    require_once('conect.php');

$submit=$_POST['submit'];

if($submit=="Save"){
    $ece_title= $_POST['ece_title'];
    $designation= $_POST['designation'];
    $qualification= $_POST['qualification'];
    $experience= $_POST['experience'];

    $repl= $_POST['repl'];

    $logo_image="";
    $success=true;

    $allowedExts = array("jpg", "jpeg", "gif", "PNG", "png", "bmp");
    $extension = end(explode(".", $_FILES["clogo"]["name"]));

    if (is_uploaded_file($_FILES["clogo"]["tmp_name"])) {
        //echo "Type: " .$_FILES["clogo"]["type"]. "<br>";
        if ((($_FILES["clogo"]["type"] == "image/gif") || ($_FILES["clogo"]["type"] == "image/jpeg") || ($_FILES["clogo"]["type"] == "image/png") || ($_FILES["clogo"]["type"] == "image/pjpeg")) && in_array($extension, $allowedExts)){
        //&& ($_FILES["clogo"]["size"] < 20000)
          if ($_FILES["clogo"]["error"] > 0)
            {
            //echo "Return Code: " . $_FILES["clogo"]["error"] . "<br />";
            $msg= "Return Code: " . $_FILES["clogo"]["error"] . "<br />";
            $success=false;
            }
          else
            {
            if (file_exists("upload/" . $_FILES["clogo"]["name"]) && $repl<>1)
              {
              //echo $_FILES["clogo"]["name"] . " already exists. ";    
              $msg = $_FILES["clogo"]["name"] . " already exists. ";    
              $success=false;
              }
            else
              {
                move_uploaded_file($_FILES["clogo"]["tmp_name"], "upload/" . $_FILES["clogo"]["name"]);
                $logo_image=$_FILES["clogo"]["name"];
                //echo "Campus Fest added Successfully.<br>";
                $success=true;
              }
            }
        }else{
          $msg= "Invalid file";
          //echo "Invalid file";
          $success=false;
        }
    }
    if($success==true){
        $QUERY= "insert into ece_faculty (title, image, designation, qualification, experience)".
                " values ('" .escapeChar($ece_title). "','" .escapeChar($logo_image). "', '" .escapeChar($designation). "',".
                "'" .escapeChar($qualification). "', '" .escapeChar($experience). "')";
        //echo "Query:$QUERY<br><br>";
        $result = mysql_query($QUERY);
        $ece_title= "";
        $logo_image= "";
        $designation= "";
        $qualification= "";
        $experience= "";
        $msg= "Facutly Details Added Successfully.<br>";
//      $msg.= "Query: $QUERY";
    }
}

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.