File Upload With Progress Bar Using PHP
Submitted by alpha_luna on Friday, April 15, 2016 - 11:11.
Good Day!!!
In this tutorial, we are going to make File Upload With Progress Bar Using PHP. In the example below, we have file input field and progress bar. During the uploading file, we are going to show the progress bar if it is done already. And, also, we have to use the jQuery and AJAX function to do this functionally. HTML File Form We have a source code for our progress bar and file input field.- <script src="js/code_js.js" type="text/javascript"></script>
- <script src="js/code_js1.js" type="text/javascript"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#upload_container').submit(function(e) {
- if($('#userImage').val()) {
- e.preventDefault();
- $('#loader-icon').show();
- $(this).ajaxSubmit({
- target: '#targetLayer',
- beforeSubmit: function() {
- $("#progress-bar").width('0%');
- },
- uploadProgress: function (event, position, total, percentComplete){
- $("#progress-bar").width(percentComplete + '%');
- $("#progress-bar").html('<div id="progress-status">' + percentComplete +' %</div>')
- },
- success:function (){
- $('#loader-icon').hide();
- },
- resetForm: true
- });
- return false;
- }
- });
- });
- </script>
Add new comment
- 1844 views