Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8782097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:28:44+00:00 2026-06-13T20:28:44+00:00

<form enctype=multipart/form-data action=upload.php method=POST> <input name=uploaded type=file /> <input type=submit value=Upload /> </form> <?php

  • 0
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input name="uploaded" type="file" />
<input type="submit" value="Upload" />
</form>

<?php
if(isset($_REQUEST['submit'])){
   $target = "data/".basename( $_FILES['uploaded']['name']) ;
   move_uploaded_file($_FILES['uploaded']['tmp_name'], $target);
}
?>

I know Javascript, AJAX and JQuery etc very well and I believe an upload progress bar can be created using PHP, AJAX and Javascript etc.

I am surprised how to get the size of upload (meaning each second I want to know, how much of the file is uploaded and how much is remaining, I think it should be possible using AJAX etc) file during upload is in process.

Here is link to the PHP manual but I didn’t understand that:
http://php.net/manual/en/session.upload-progress.php

Is there any other method to show the upload progress bar using PHP and AJAX but without use of any external extension of PHP? I don’t have access to php.ini

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:28:47+00:00Added an answer on June 13, 2026 at 8:28 pm

    Introduction

    The PHP Doc is very detailed it says

    The upload progress will be available in the $_SESSION superglobal when an upload is in progress, and when POSTing a variable of the same name as the session.upload_progress.name INI setting is set to. When PHP detects such POST requests, it will populate an array in the $_SESSION, where the index is a concatenated value of the session.upload_progress.prefix and session.upload_progress.name INI options. The key is typically retrieved by reading these INI settings, i.e.

    All the information you require is all ready in the PHP session naming

    • start_time
    • content_length
    • bytes_processed
    • File Information ( Supports Multiple )

    All you need is to extract this information and display it in your HTML form.

    Basic Example

    a.html

    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
    rel="stylesheet" type="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    <script type="text/javascript">
        var intval = null;
        var percentage = 0 ;
        function startMonitor() {
            $.getJSON('b.php',
            function (data) {
                if (data) {
                    percentage = Math.round((data.bytes_processed / data.content_length) * 100);
                    $("#progressbar").progressbar({value: percentage});
                    $('#progress-txt').html('Uploading ' + percentage + '%');
    
                }
                if(!data || percentage == 100){
                    $('#progress-txt').html('Complete');
                    stopInterval();
                }
            });
        }
    
        function startInterval() {
            if (intval == null) {
                intval = window.setInterval(function () {startMonitor()}, 200)
            } else {
                stopInterval()
            }
        }
    
        function stopInterval() {
            if (intval != null) {
                window.clearInterval(intval)
                intval = null;
                $("#progressbar").hide();
                $('#progress-txt').html('Complete');
            }
        }
    
        startInterval();
    </script>
    

    b.php

    session_start();
    header('Content-type: application/json');
    echo json_encode($_SESSION["upload_progress_upload"]);
    

    Example with PHP Session Upload Progress

    Here is a better optimized version from PHP Session Upload Progress

    JavaScript

    $('#fileupload').bind('fileuploadsend', function (e, data) {
        // This feature is only useful for browsers which rely on the iframe transport:
        if (data.dataType.substr(0, 6) === 'iframe') {
            // Set PHP's session.upload_progress.name value:
            var progressObj = {
                name: 'PHP_SESSION_UPLOAD_PROGRESS',
                value: (new Date()).getTime()  // pseudo unique ID
            };
            data.formData.push(progressObj);
            // Start the progress polling:
            data.context.data('interval', setInterval(function () {
                $.get('progress.php', $.param([progressObj]), function (result) {
                    // Trigger a fileupload progress event,
                    // using the result as progress data:
                    e = document.createEvent('Event');
                    e.initEvent('progress', false, true);
                    $.extend(e, result);
                    $('#fileupload').data('fileupload')._onProgress(e, data);
                }, 'json');
            }, 1000)); // poll every second
        }
    }).bind('fileuploadalways', function (e, data) {
        clearInterval(data.context.data('interval'));
    });
    

    progress.php

    $s = $_SESSION['upload_progress_'.intval($_GET['PHP_SESSION_UPLOAD_PROGRESS'])];
    $progress = array(
            'lengthComputable' => true,
            'loaded' => $s['bytes_processed'],
            'total' => $s['content_length']
    );
    echo json_encode($progress);
    

    Other Examples

    • Tracking Upload Progress with PHP and JavaScript
    • PHP-5.4-Upload-Progress-Example
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HTML <form enctype=multipart/form-data id=SubmitForm method=post action=serv.php> <input type=file name=IMG size=chars> <input type=Submit value=SAVE> </form>
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
I have an upload box... <form action=upload_file.php method=post enctype=multipart/form-data><BR> <label for=file>Filename:</label><BR> <input type=file name=file
I am initializing file upload using the following HTML: <form enctype=multipart/form-data action=PHPScripts/upload.php method=POST> <input
$(function() { $(.preview).click(function() { $('#image').wrap('<form action=/index/upload.php method=post enctype=multipart/form-data id=imageform target=imageupload />'); $('#imageform').submit(); $('#image').unwrap(); var
I have the following form <form name=myForm id=myForm method=post enctype=multipart/form-data action=script.php> and this jQuery
I have this html form <form enctype=multipart/form-data action=upload.php method=POST> <textarea rows=5 cols=50 name=links id=links
I have the following form: <html> <body> <form action=upload_file.php method=post enctype=multipart/form-data> <label for=file>Filename:</label> <input
I have the following in jsp: <form action=/ucReady2/uploadservlet method=post enctype=multipart/form-data> <label for=filename_1>File: </label> <input
I have next form and some ashx <form action=FileUpload.ashx method=POST enctype=multipart/form-data id=frmUpload> <input id=fileupload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.