0

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

Edited by pritaeas: Moved.

6
Contributors
8
Replies
67
Views
4 Years
Discussion Span
Last Post by diafol
0

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

0

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.

0

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";
    }
}

?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.