Jump to content

Recommended Posts

Hello everyone.

 

For a long time I have been searching for a working php / javascript file upload progress bar.

(working without flash or perl or php extensions).

 

I recently found a project which is exactly doing that:

http://sourceforge.net/projects/upu/

(It is showing a accurate progress bar while uploading).

 

However, I want to understand how this works.

It makes a socket and listens to it, or smth like that.

 

Can anyone tell me how this script generates the progress bar?

Link to comment
https://forums.phpfreaks.com/topic/188466-upu-file-upload/
Share on other sites

Too bad the author did not publish any information or host a forum on the sourceforge site. Have you checked his direct site, which unfortunately is not in English.

 

Short version of what it is doing -

 

The script uses AJAX in the browser to submit to an iframe. This allows the status to be fetched from the server and updated on the page while the upload is in progress. This is pretty standard for doing things like displaying an upload 'activity' (not to be confused with upload progress) indicator and for displaying upload error messages.

 

What the code is doing differently that allows the upload progress to work, is it starts a php script that opens a socket connection that listens on a specific (randomly picked) port number. There is also a process id number assigned. The port number and process id are passed back to the javascript running in the browser. The browser submits the form data to the correct port number so that the php script is actually used to receive and process the uploaded data.

 

The javascript code that gets and displays the progress is again using AJAX and periodically makes http requests to the getinfo.php page, providing the specific process id on the end of the URL. This page uses the specific process id to get information about the matching file being uploaded and returns that information to the browser where it can be displayed.

 

Do you have a more specific question that was not answered already?

Link to comment
https://forums.phpfreaks.com/topic/188466-upu-file-upload/#findComment-995030
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.