Search
 
SCRIPT & CODE EXAMPLE
 

PHP

upload image to mysqli database

<?php // Include the database configuration file  require_once 'dbConfig.php';  // If file upload form is submitted $status = $statusMsg = ''; if(isset($_POST["submit"])){     $status = 'error';     if(!empty($_FILES["image"]["name"])) {         // Get file info         $fileName = basename($_FILES["image"]["name"]);         $fileType = pathinfo($fileName, PATHINFO_EXTENSION);                  // Allow certain file formats         $allowTypes = array('jpg','png','jpeg','gif');         if(in_array($fileType, $allowTypes)){             $image = $_FILES['image']['tmp_name'];             $imgContent = addslashes(file_get_contents($image));                      // Insert image content into database             $insert = $db->query("INSERT into images (image, uploaded) VALUES ('$imgContent', NOW())");                          if($insert){                 $status = 'success';                 $statusMsg = "File uploaded successfully.";             }else{                 $statusMsg = "File upload failed, please try again.";             }          }else{             $statusMsg = 'Sorry, only JPG, JPEG, PNG, & GIF files are allowed to upload.';         }     }else{         $statusMsg = 'Please select an image file to upload.';     } }  // Display status message echo $statusMsg; ?>
Comment

PREVIOUS NEXT
Code Example
Php :: sendmail folder missing in xampp 
Php :: php html text before first h2 tag 
Php :: php array form 
Php :: WooCommerce shop loop random array function not same values after each other 
Php :: how convert the string to int in laravel function event 
Php :: data XML 
Php :: php how to check if user has a role on login 
Php :: cookie phpsessid will be soon treated as cross-site cookie against 
Php :: Remove the additional notes area from the WooCommerce checkout 
Php :: laravel $browser-keys alt click 
Php :: php sdk paytm 
Php :: how to set default php version in ubuntu 
Php :: php file handling 
Php :: wp functions ajax get 
Php :: cpt change link 
Php :: discord.py Levels 
Php :: html add div around certain iframe php 
Php :: Laravel FileManager Display Blank pop up page 
Php :: random record get with pagination in karavel 8 
Php :: how to duplicate a database in phpmyadmin 
Php :: $name = $name; "Robert" echo; 
Php :: Find template serving current page 
Php :: PHP str_getcsv — Parse a CSV string into an array 
Php :: How to return custom error message from controller method validation 
Php :: bootstrap carousel foreach loop not working wordpressp php wp 
Php :: laravel repository error 
Php :: php random array name 
Php :: woocommerce hook after order complete 
Php :: php join array to parenthesis 
Php :: composer exceeded the timeout of 300 seconds. 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =