PHP Simple Image Upload and Display Source Code

PHP Simple Image Upload and Display Source Code

In this Post We Will Explain About is PHP Simple Image Upload and Display Source Code With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to PHP code for image upload and display Example

In this post we will show you Best way to implement How to Upload Files on Server in PHP, hear for ,
with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

In this post we will make a HMTL to Simple Image Upload using script of the PHP. PHP is a web based server-side PHP scripting language designed mainly primarily for ss side web development. this is a learn and consistent directory way to access mysql databases. This stand developers can script write portable source code more easier. It is best used by a newly freshar coders for its any user or developers user friendly environment. therefor Let’s do the source coding.

Also Read This πŸ‘‰   PHP warning: invalid argument supplied for foreach()

making the database dbconection

first of all the Open your mysql any kind of text simple editor( Like as a notepadd++, etc..). and Then just simple copy and paste the source code below after that name it dbcon.php.

	$dbcon = new mysqli('hostname', 'root', 'password', 'db_pic_name');
		die("Error!: sorry Cannot dbconect to the database!");

Making The Interface

This is where I will make a simple form for our application. To make the HTML forms simply source code copy and write it into you text notepad editor, and then save data it as shown below source code.


<!DOCTYPE html>
<html lang="en">
		<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
		<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
	<nav class="navbar navbar-default">
		<div class="container-fluid">
			<a class="navbar-brand" href=""></a>
	<div class="col-sm-3"></div>
	<div class="col-sm-6 well">
		<h3 class="text-primary">Simple PHP - Simple Image Upload - pakainfo</h3>
		<hr style="border-top:1px dotted #ccc;"/>
		<div class="col-sm-2"></div>
			<form method="POST" action="live_save_upload.php" enctype="multipart/form-data">
				<input type="text" name="name"/>
				<div style="float:right;">
					<div id = "picture_prev_display" style = "width:150px; height :150px; border:1px solid #000;">
						<center id = "myimg">[Photo]</center>
					<input type = "file" id = "mypicImg" name = "mypicImg" />
				<div style="clear:both;"></div>
				<center><button class="btn btn-primary" name="submit"><span class="glyphicon glyphicon-save"></span> Save</button></center>
		<br />
		<div class="col-sm-12">
			<table class="pakainfo table table-bordered exlive">
						<th>User Name</th>
						require 'dbcon.php';
						$squry = $dbcon->query("SELECT * FROM `students`") or die(mysqli_errno());
						while($retrive = $squry->retrive_array()){
						<td><?php echo $retrive['name']?></td>
						<td><center><img src="<?php echo "upload/".$retrive['mypicImg']?>" width="100px" height="100px"></center></td>
<script src="pakainfo/js/jquery-3.2.1.min.js"></script>
<script type = "text/javascript">
		$pic = $('<img id = "image" width = "100%" height = "100%"/>');
		$myimg = $('<center id = "myimg">[Photo]</center>');
			var files = !!this.files ? this.files : [];
			if(!files.length || !window.FileReader){
				var dreadr = new FileReader();
				dreadr.onloadend = function(){
					$("#image").attr("src", this.result);

Creating the Main Function

This source code data contains the specific source code for the upload. This will data process the upload image file that have been upload then will save it to a designated folder. To do that Copy and paste these source code block of source codes inside the main Text editor Like as notepad++ and call it as live_save_upload.php.

Also Read This πŸ‘‰   PHP Web Application create Installer scripts

	require_once 'dbcon.php';
		if($_FILES['mypicImg']['name'] != "" && $_POST['name'] != ""){
			$name = $_POST['name'];
			$pic_name = $_FILES['mypicImg']['name'];
			$pic_temp = $_FILES['mypicImg']['tmp_name'];
			$pic_extention = explode('.', $pic_name);
			$image = time().".".end($pic_extention);
			move_uploaded_file($pic_temp, "upload/".$image);
			$dbcon->query("INSERT INTO `students` VALUES('', '$name', '$image')") or die(mysql_errno());

so you have it I successfully make a PHP source code example Simple Image Upload using HTML and PHP. I hope that this simple Post help you to what you are looking for. For more many example updates and post and services just kindly all the example and tags visit this site. Good Luck Enjoy Coding!!!

Also Read This πŸ‘‰   how to Social Media Sharing Buttons in php?

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example


I hope you have Got What is PHP code for image upload and display And how it works.I would Like to have FeedBack From My Blog( readers.Your Valuable FeedBack,Any Question,or any Comments about This Article( Are Most Always Welcome.