Search
 
SCRIPT & CODE EXAMPLE
 

PHP

update image in database using php

<?php
    	require_once 'conn.php';
    	if(ISSET($_POST['save'])){
    		$image_name = $_FILES['photo']['name'];
    		$image_temp = $_FILES['photo']['tmp_name'];
    		$firstname = $_POST['firstname'];
    		$lastname = $_POST['lastname'];
    		$exp = explode(".", $image_name);
    		$end = end($exp);
    		$name = time().".".$end;
    		if(!is_dir("./upload"))
    			mkdir("upload");
    		$path = "upload/".$name;
    		$allowed_ext = array("gif", "jpg", "jpeg", "png");
    		if(in_array($end, $allowed_ext)){
    			if(move_uploaded_file($image_temp, $path)){
    				mysqli_query($conn, "INSERT INTO `user` VALUES('', '$firstname', '$lastname', '$path')") or die(mysqli_error());
    				echo "<script>alert('User account saved!')</script>";
    				header("location: index.php");
    			}	
    		}else{
    			echo "<script>alert('Image only')</script>";
    		}
    	}
    ?>
Comment

PREVIOUS NEXT
Code Example
Php :: html to pdf in php 
Php :: comment php 
Php :: check if date has passed php 
Php :: recursive binary search php 
Php :: php string search in array 
Php :: copy folder contect to anthor folder php 
Php :: wordpress how to match password 
Php :: How To Check If A String Ends With Another String In PHP 
Php :: acf create post with fields 
Php :: select option in laravel 
Php :: qr code generator php 
Php :: define constructor in trait php 
Php :: php slice last arrat 
Php :: php cookies 
Php :: h:i:s explode in php by ":" 
Php :: for each multiple php 
Php :: return with success message laravel 
Php :: laravel middleware in constructor 
Php :: sql update row in php 
Php :: laravel undefined index 
Php :: luhn algorithm 
Php :: php How to add custom button in wordpress admin section 
Php :: php substr 
Php :: pmxi_gallery_image 
Php :: php != operator 
Php :: $_get and $_post in php 
Php :: laravel where 2 column 
Php :: laravel bd query 
Php :: php convert array to json 
Php :: configuration laravel dompdf 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =