jQuery Ajax File Upload Progress Bar percentage in PHP

Today, We want to share with you jQuery Ajax File Upload Progress Bar percentage in PHP.In this post we will show you File Upload Progress Bar Using jQuery And PHP, hear for jQuery Ajax Image Upload with Animating Progress Bar we will give you demo and example for implement.In this post, we will learn about Ajax File Upload with Progress Bar using PHP JQuery with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

jQuery Ajax File Upload Progress Bar percentage in PHP

There are the Following The simple About jQuery Ajax File Upload Progress Bar percentage in PHP Full Information With Example and source code.

As I will cover this Post with live Working example to develop File upload progress bar with jQuery, so the some major files and Directory structures for this example is following below.

  • index.php
  • uploadFile.php
  • style.css
  • jquery.form.min.js

HTML Form Interface


This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.php.

<title>jQuery Ajax File Upload Progress Bar percentage in PHP</title>

$(document).ready(function () {
    $('#frmBtnSubmit').click(function () {
    	        target: '#previewImg',
    	        url: 'uploadFile.php',
    	        beforeSubmit: function () {
    	        	   if($("#mediaUpload").val() == "") {
    	        		   $("#previewImg").html("<div class='error'>Select a file to upload.</div>");
                    return false; 
    	            $("#progressDivId").css("display", "block");
    	            var progressPcentValue = '0%';

    	        uploadProgress: function (event, position, total, progressPcentComplete) {

    	            var progressPcentValue = progressPcentComplete + '%';
    	                width: '' + progressPcentValue + ''
    	            }, {
    	                duration: 5000,
    	                easing: "linear",
    	                step: function (x) {
                        progressPcentText = Math.round(x * 100 / progressPcentComplete);
    	                    $("#progressPcent").text(progressPcentText + "%");
                        if(progressPcentText == "100") {
    	        error: function (response, status, e) {
    	            alert('Oops something went.');
    	        complete: function (xhr) {
    	            if (xhr.txtResults && xhr.txtResults != "error")
        	            	$("#previewImg").html("<div class='error'>Sorry, Problem in uploading file.</div>");

    <h1>jQuery Ajax File Upload Progress Bar percentage in PHP</h1>
    <div class="form-container">
        <form action="uploadFile.php" id="uploadForm" name="frmupload" method="post" enctype="multipart/form-data">

        <div class='progress' id="progressDivId">
            <div class='progress-bar' id='liveProgress'></div>
            <div class='progressPcent' id='progressPcent'>0%</div>
        <div style="height: 15px"></div>
        <div id='previewImg'></div>

PHP File Upload Source Code


if (isset($_POST['btnSubmit'])) {
    $uploadfile = $_FILES["mediaUpload"]["tmp_name"];
    $targetPath = "uploads/";
    if (! is_writable($targetPath) || ! is_dir($targetPath)) {
        echo "error";
    if (move_uploaded_file($_FILES["mediaUpload"]["tmp_name"], $targetPath . $_FILES["mediaUpload"]["name"])) {
        echo '<img>';

jQuery Ajax Image Upload – Custom CSS Style


body {
    font-family: Arial;
    width: 550px;
    padding: 15px

.form-container {
    background: #F0F0F0;
    border: #e0dfdf 1px solid;
    padding: 20px;
    border-radius: 2px;
    width: 550px;
    height: 450px;

form {
    display: block;
    margin: 15px;
    background: #d3d3d3;
    border-radius: 5px;
    padding: 15px

.progress {
    display: none;
    position: relative;
    margin: 20px;
    width: 400px;
    background-color: #ddd;
    border: 1px solid blue;
    padding: 1px;
    left: 15px;
    border-radius: 5px;

.progress-bar {
    background-color: green;
    width: 0%;
    height: 30px;
    border-radius: 4px;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;

.progressPcent {
    -webkit-border-radius: 4px;
    color: #fff;
    display: inline-block;
    font-weight: bold;
    left: 50%;
    margin-left: -20px;
    margin-top: -9px;
    position: absolute;
    top: 50%;

#previewImg {
    display: none;

.error {
    background: #ffb3b3;
    border-radius: 5px;
    border: #f1a8a8 1px solid;
    box-sizing: border-box;
    color: #ad7b7b;
    margin: 15px;
    padding: 15px;

input#mediaUpload {
    border: #3d3d3d 1px solid;
    padding: 6px;
    border-radius: 5px;

#previewImg img {
    max-width: 300px;

#frmBtnSubmit {
    background: #9a9a9a;
    border-radius: 5px;
    border: #898a89 1px solid;
    color: #F0F0F0;
    font-size: 0.8em;
    margin-left: 15px;
    padding: 7px 20px;

.error {

jQuery Ajax File Upload Progress Bar percentage – Output

jQuery Ajax Image Upload with Animating Progress Bar – Download Source code
Angular 6 CRUD Operations Application Tutorials

Read :


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

I hope you get an idea about jQuery Ajax File Upload Progress Bar percentage in 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.

Related FAQ

Here are some more FAQ related to this Article:

  1.   jQuery Ajax File upload with Percentage Progress bar using PHP MySQLi
  2.   PHP Ajax dynamic Progress Bar for PHP AJAX File Upload
  3.   jquery $.inArray Method with Example
  4.   How To Add Flash Messages in Laravel 6 Session?
  5.   Like Dislike system with PHP and MySQL
  6.   Pop Push Shift Unshift Array Methods
  7.   Laravel 6 Client Ip Address – How to get Client Ip Address in Laravel 6?
  8.   ng-table Sorting using Angular Example
  9.   How to display pdf file in HTML - PDF Viewer HTML5 Example
  10.   PHP Laravel Limit String Length (Truncate string) Example

Leave a Reply

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