Update and upload image to Directory and database

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
asareza
New php-forum User
New php-forum User
Posts: 1
Joined: Fri Oct 22, 2021 6:04 am

Hi, I have a code for update a logo and insert to database, but i need when update logo, my image upload in directory (img)
This code:

Code: Select all

<?php
   if (isset($_POST["btn_upd_setting"]))

   {
   
   mysqli_query($link,"update setting set logo='". $_POST["logo"]. "'");
   $folder = "image/".$filename; 
   
   echo '<div class="ok container text-center">Update completed successfull!</div>';
   }
   
   
   $meta_title_section="empty...";
   $sql_setting=mysqli_query($link,"select * from setting limit 1");
   
   if ($sql_setting && mysqli_num_rows($sql_setting)==1)
   {
   $reader_setting=mysqli_fetch_assoc($sql_setting);
   
   }
   ?>
   <div class="col-md-12">
      <br>
      <form class="setting-form" method="post">
         <div class="form-group">
            <label for="logo">Logo</label>
            <input id="logo" name="logo" type="file" class="form-control" >
         </div>
         
         <div class="form-group">
            <input type="submit" value="Edit Section" class="btn btn-warning" name="btn_upd_setting">
         </div>
      </form>
   </div>

 <!-------- Show Image--------->  
   <img src="../img/<?php echo $reader_setting["logo"];  ?>" alt="">
AdoptiveSolution
php-forum GURU
php-forum GURU
Posts: 218
Joined: Wed Jun 15, 2016 8:35 am

Here’s code to upload an image, save the name in a database and save the image in a folder.
Then display the image(s).

https://www.codexworld.com/upload-store ... php-mysql/

If you use this, you can search for more.

upload store image file in database using php mysql
Post Reply