Posted inTechnology / Ajax / jQuery / php

jQuery Ajax Image Upload without Page Refresh using PHP

Today, We want to share with you jQuery Ajax Image Upload without Page Refresh using PHP.
In this post we will show you Ajax file upload, hear for simple ajax file upload jquery we will give you demo and example for implement.In this post, we will learn about Image Upload without Page Refresh with PHP and jQuery with Demo with an example.

jQuery Ajax Image Upload without Page Refresh using PHP

There are the Following The simple About jQuery Ajax Image Upload without Page Refresh using PHP Full Information With Example and source code for PHP Image Upload without Page Refresh and jQuery Tutorials.

Main HTML Interface for Image Upload

index.php


Select You Profile Image File:


clients Table

CREATE TABLE IF NOT EXISTS `clients` (
`clientid` int(11) NOT NULL AUTO_INCREMENT,
`client` varchar(255) DEFAULT NULL,
`pass` varchar(100) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`profile_photo` varchar(200) DEFAULT NULL,
PRIMARY KEY (`clientid`),
UNIQUE KEY `username` (`client`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

profile_images_upload.php

<?php
$path = "medias/";
$file_format_valid_check = array("jpg", "png", "gif", "bmp","jpeg");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
{
$name = $_FILES['client_profile']['name'];
$size = $_FILES['client_profile']['size'];
if(strlen($name)) {
list($txt, $ext) = explode(".", $name);
if(in_array($ext,$file_format_valid_check)) {
if($size<(1024*1024)) {
$client_profile_name = time().$client_session_id.".".$ext;
$tmp = $_FILES['client_profile']['tmp_name'];
if(move_uploaded_file($tmp, $path.$client_profile_name)){
mysql_query("UPDATE clients SET profile_photo='$client_profile_name' WHERE clientid='$client_session_id'");
echo "jQuery Ajax Image Upload without Page Refresh";
}
else
echo "sorry, client_profile Upload failed";
}
else
echo "client_profile file size maximum 1 MB, please try again.";
}
else
echo "Invalid your uploaded file format";
}
else
echo "Please select your Good Profile image";
exit;
}
?>

upload.js

The file main jQuery upload.js Data contains source code to HTML submit form when your pictures file uploaded to fully submit pictures upload futures with profile_images_upload.php. The file also displays pictures upload main wait loader.

$(document).ready(function() {
$('#client_profile').live('change', function() {
$("#img_preview").html('');
$("#img_preview").html('Yout Profile Image Uploading....');
$("#profile_images_upload_frm").ajaxForm({
target: '#img_preview'
}).submit();
});
});

Read :

Angular 6 CRUD Operations Application Tutorials

Summary

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

I hope you get an idea about Ajax Image Upload without Refreshing Page using Jquery.
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.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype