Search
 
SCRIPT & CODE EXAMPLE
 

PHP

add image php database

<?php
error_reporting(0);
?>
<?php
  $msg = "";
  
  // If upload button is clicked ...
  if (isset($_POST['upload'])) {
  
    $filename = $_FILES["uploadfile"]["name"];
    $tempname = $_FILES["uploadfile"]["tmp_name"];    
        $folder = "image/".$filename;
          
    $db = mysqli_connect("localhost", "root", "", "photos");
  
        // Get all the submitted data from the form
        $sql = "INSERT INTO image (filename) VALUES ('$filename')";
  
        // Execute query
        mysqli_query($db, $sql);
          
        // Now let's move the uploaded image into the folder: image
        if (move_uploaded_file($tempname, $folder))  {
            $msg = "Image uploaded successfully";
        }else{
            $msg = "Failed to upload image";
      }
  }
  $result = mysqli_query($db, "SELECT * FROM image");
?>
Comment

PREVIOUS NEXT
Code Example
Php :: how to pass token with post request laravel 
Php :: php artisan make :migration with model 
Php :: distinct laravel not working 
Php :: get recoed between two datetime laravel 
Php :: magento 2 get number of cart items 
Php :: __invoke in laravel 
Php :: php get bool from string 
Php :: wordpress remove taxonomy from post 
Php :: install laravel on windows 
Php :: php unique associative array by value 
Php :: eloquent where comparing two columns 
Php :: laravel switch 
Php :: route laravel Target class [AuthController] does not exist 
Php :: upload images php mysql 
Php :: get all class methods php 
Php :: laravel image store 
Php :: declare variable in php class 
Php :: add another column in a table in laravel 
Php :: return view inside subfolder laravel 
Php :: how to check the day of any date in php 
Php :: php get all array keys in json 
Php :: seprate day and year from laravel to timestamp 
Php :: - in php 
Php :: replace word in string php 
Php :: switch php version ubuntu 20.04 
Php :: find value in array php 
Php :: laravel blade php variable concatenate javascript variable 
Php :: how to print on console with phpunit 
Php :: how to create static variable in model laravel 
Php :: php command get ini params 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =