I want to insert image path in database using MYSQL in PHP -


i want insert image path in database. in browser when user selects image path , image store in image folder , path store in database. tried if ($type==...) part not working. going else statement.

edited :

if (isset($_post['bsubmit'])) {  var_dump($_files);     $name = $_files['file']['name'];      $type=var_dump($_files['file']['type']);        if ($type == 'image/jpeg' || $type == 'image/png' || $type == 'image/gif') {         if (file_exists(dirname($_server['document_root']) . '/htdocs/amit_404_store/img/' . $name)) {             echo 'file present';         } else {             $uploadimage = move_uploaded_file($_files['file']['tmp_name'], dirname($_server['document_root']) . '/htdocs/amit_404_store/img/' . $name);             echo "stored in: " . "" . $name . "<br />";             $destination = $name;             echo "upload in: " . "" . $destination . "<br />";              //database connection             $servername = "localhost";             $username   = "root";             $password   = "";             $database   = "new_404_store2";              //session value store , retrive data index.html file             $email = $_session['user_name1'];              $conn = mysqli_connect($servername, $username, $password, $database);              if (mysqli_connect_errno()) {                 echo "failed connect mysql: " . mysqli_connect_error();             }              $update_query = "update customer_information2 set image_path='$destination' email_id='$email'";              $result = mysqli_query($conn, $update_query);                if (!$result) {                 die('could not enter data: ' . mysqli_error());             }               if ($uploadimage) {                 echo 'image uploaded , stored';             } elseif (!$uploadimage) {                 echo 'image not uploaded';             }          }     } else {         echo 'invalid file type';     } }  //mysqli_close($conn); ?> 

you have not written enctype,it required file transfer

<form method="post" action="example4.php" id="frmorderdetailsgraphic" class="" autocomplete="off"   enctype="multipart/form-data">  

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -