In this post we will learn how to make File upload progress bar. We have also covered a tutorial about ajax file upload. But in that tutorial, we were not showing the progress of file upload. A mandatory feature is to show the progress bar when the file is being uploaded to the server.
For server side I am going to use PHP. We will also use HTML and CSS for our designing File upload progress bar. To apply the progress bar we will use jQuery form plugin.
You can check this video demo before starting the tutorial File upload progress bar.
Creating our PHP Project
- I am using wamp server. You can use any PHP server. So for wamp we have the root directory which is www (c: / wamp / www) in case of wamp.
- Now create a new folder inside the root directory. I loaded the fileup.
- First of all create an HTML file named index.html. Inside this file, we will create our html form. You can create a form using the following code.
Have 1 2 3 4 5 4 . . 4 10 1 1 12 13 14 15 14 1. 1. 19 20 21 22 23 24 25 24 2. |
<!DOCTYPE html> <html> <Head> <!– Is adding jQuery –> <Script src=“https://code.jquery.com/jquery-2.2.0.min.js”> <!– Is adding Junkery Form to set –> <Script src=“.os.maxcdn.com / jquery.form / 3.50 / jquery.form.min.js”> </Head> <Body> <!– Our Form –> <Form way=‘Post’ The action=‘upload.php’ Superstructure=‘Multipart / form-data’> <Input Type=‘File’ Name=‘File’ /> <switch>Pour</switch> </Form> <!– Area To Show off Is the percentage Of Progress –> <div Id=”></div> <!– Area To Show off a message After ending Of Pour –> <div Id=‘Event’></div> </Body> </html> |
- Now we need to make Upload File to handle file upload.
Have 1 2 3 4 5 4 . . 4 10 1 1 12 13 14 15 14 1. 1. 19 20 21 22 |
<? php // request checking If()$ _SERVER[‘REQUEST_METHOD’]==‘Post’){{ // get file $ File = $ _FILES[‘file’][‘tmp_name’]; // get the file name $ Name = $ _FILES[‘file’][‘name’]; // upload path $ Path = ‘Upload /’; // storing the file in place Move_uploaded_file()$ File,$ Path.$ Name); // Displaying success message Echo ‘Success’; } |
- Now finally we need to write the following script inside the html page to make it work.
Have 1 2 3 4 5 4 . . 4 10 1 1 12 13 14 15 14 1. 1. 19 20 21 22 23 24 25 24 |
$()The ceremony()) {{ $()The document).ready()The ceremony()){{ Where Is the percentage = $()‘# Percent’); Where Event = $()‘#Event’); $()‘Form’).ajaxForm(){{ Pre send: The ceremony()) {{ Event.Empty()); Where Percent = ‘0%’; Is the percentage.html()Percent); }, Uploadpro: The ceremony()The competition, Post, The total, percent complete) {{ Where Percent = percent complete + ‘%’; Is the percentage.html()Percent); }, full: The ceremony()xhr) {{ Event.html()xhr.responseText); } }); }); });
|
- That’s it, now try to run your application. You can see the output given below.
- We can make it more cold by using it Css.
Implementing CSS in file upload progress bar
- Modify your first index.html Please enter as below.
Have 1 2 3 4 5 4 . . 4 10 1 1 12 13 14 15 14 1. 1. 19 20 21 22 23 24 25 24 2. 2. 29 30 31 32 33 34 35 37 3. 3. 39 40 41 42 43 4 45 4 ४ 47 ४ 48 ४ ९ 50 51 52 53 58 55 |
<!DOCTYPE html> <html> <Head> <Script src=“https://code.jquery.com/jquery-2.2.0.min.js”> <Script src=“.os.maxcdn.com / jquery.form / 3.50 / jquery.form.min.js”> <Contact rel=‘Style sheet’ href=‘style.css’ /> </Head> <Body> <div class=‘Training’> <h2>The file Pour Progress times Examples</h2> <Form way=‘Post’ The action=‘upload.php’ Superstructure=‘Multipart / form-data’> <Input Type=‘File’ Name=‘File’ /> <switch>Pour</switch> </Form> <div Id=“Bairia”> <div Id=“times”></div> </div> <div Id=”></div> <div Id=‘Event’></div> </div>
$()The ceremony()) {{ $()The document).ready()The ceremony()){{ Where times = $()‘# times’) Where Is the percentage = $()‘#percent’); Where Event = $()‘#Event’); $()‘Form’).ajaxForm(){{ Pre send: The ceremony()) {{ Event.Empty()); Where Percent = ‘0%’; times.The width()Percent); Is the percentage.html()Percent); }, Uploadpro: The ceremony()The competition, Post, The total, percent complete) {{ Where Percent = percent complete + ‘%’; Is the percentage.html()Percent); times.The width()Percent); }, full: The ceremony()xhr) {{ Event.html()xhr.responseText); } }); }); });
</Body> </html> |
- And create a file named The style And add the following CSS code.
Have 1 2 3 4 5 4 . . 4 10 1 1 12 13 14 15 14 1. 1. 19 20 21 22 23 24 25 24 2. 2. 29 30 31 32 |
Body{{ font size:120%; line height:2; font family:Calibari; } .Training{{ The width:60%; Margin:0 Auto; Back color:# 6082bb; Text align:center; Padding:4%; Range radius:5 px; } # Baria{{ The width:100%; The height:40 px; Limit:2 px Solid #Faf; } #times{{ The width:1%; Margin:4 px 0; The height:32 px; Back color:#Faf; } #Event{{ colour:# liar; } |
- Now you will see the following output.
- You can go This link To test the uploader.
- You can also download my source code in case of problems.
[download id=”2196″]
So for this we have to File upload progress bar Tutorial. Feel free to ask any confusion or questions about this tutorial. Thank you 🙂


Hi, my name is Belal Khan and I am Google Developers Specialist (GDE) for Android. A passion for teaching made me this blog. If you are an Android developer, or you are learning about Android development, I can help you a lot with simplified coding.
Source link