Simple Ajax Upload image using jQuery PHP

Today, We want to share with you Simple Ajax Upload image using jQuery PHP.In this post we will show you how to insert image in database using ajax in php, hear for ajax image upload without refreshing page using jquery we will give you demo and example for implement.In this post, we will learn about Upload Image Without Page Refresh Using Ajax,jQuery And PHP with an example.

Read Also:  PHP and Ajax Asynchronous File Upload using jQuery

Simple Ajax Upload image using jQuery PHP

There are the Following The simple About Simple Ajax Upload image using jQuery PHP Full Information With Example and source code.

As I will cover this Post with live Working example to develop jquery ajax image upload with preview, so the some upload image using ajax in php for this example is following below.

Upload image using ajax jquery

index.html


<title>Upload Image Using Ajax Example - pakainfo.com</title>



<form method="post" action="upload.php" id="upload">


</form>
<div id="img_preview"></div>

jQuery("#upload").submit(function(e){
	jQuery.ajax({
			url: "do_upload.php",
			dataType: "json",
			type: "POST",             
			data: new FormData(this), 
			contentType: false,       
			processData:false,        
			cache: false,
			success: function(response){
			console.log(response);
			if(response.is_status == "1"){
				jQuery("#img").val("");
				jQuery("#img_preview").html('<img src='+response.img+'>');
			}else if(response.is_status == "0"){
				alert(response.msg);
			}
		}
	}); 
	e.preventDefault();
});



do_upload.php

Read Also:  PHP Image Resize, Crop, Thumbnail, Watermark

When simple YOur Live image is uploaded to server side in PHP format it return output in sample json format.

 1, "img" => $name);
}else{
	$res = array("is_status" => 0, "msg" => "error");
}
header("content-type: application/json");
echo json_encode($res);
?>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Simple Ajax Upload image using jQuery PHP.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  jQuery AJAX file Image upload PHP Example

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  jQuery Ajax File Upload images using PHP MySQLi
  2. Read Also:  jQuery Ajax Image Upload without Page Refresh using PHP
  3. Read Also:  paypal express checkout woocommerce Integration
  4. Read Also:  jQuery AJAX Multiple Files Upload using PHP
  5. Read Also:  payment gateway form php source code
  6. Read Also:  How to Get Current Date & Time in Python
  7. Read Also:  jquery ajax image upload preview codeigniter
  8. Read Also:  Laravel Convert Array To Collection Example
  9. Read Also:  PHP Dynamically Add Remove Images Upload using Ajax
  10. Read Also:  Angular2 Datatable Pagination, Sorting and Searching
CLOSEX