NetTalk Central

Author Topic: File Upload Tracking  (Read 4441 times)

CyberFerret

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
File Upload Tracking
« on: July 23, 2008, 09:51:12 PM »
Hi all,

We are playing with an app here using NetTalk WebServer  to handle large file uploading, and one of the requirements from the customer is to have a progress bar giving the upload percentage on the file(s).

Does the webserver component have the capacity to have a callback which can pass the current uploaded size back to an Ajax query from the client end?  File is submitted via a standard POST, but if we could get (a) the file size and (b) current uploaded byte count, that would be fantastic.

Cheers,
Devan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File Upload Tracking
« Reply #1 on: July 24, 2008, 12:12:53 AM »
Hi Devan,

It's been a while since I experimented with this.

As I recall, once you do the POST you're not gonna get anything to update on the window until the post is completed.

Thus in order to have the progress bar, you need to do the Post as the ajax call, and then use a timer to update the progress. There are scripts out there that do this sort of thing, but I've not integrated any in yet.

Cheers
Bruce

CyberFerret

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: File Upload Tracking
« Reply #2 on: July 24, 2008, 12:49:20 AM »
Thanks for your reply Bruce.

Hunting around Google, I note that there was a PHP 4.x extension that allowed you to do this and apparently PHP 5.2x allows this natively now, but not sure how, because as you said, I thought the POST command itself is not asynchronous.

One other PHP workaround I found was do to a periodic AJAX call back to the server during the upload which called a script that checked the file size in the temporary upload folder that PHP used.

I am certain we can replicate that here with a simple Web Source procedure that looks in the NetTalk upload folder for the file size - that is it NetTalk writes the file as a byte stream and doesn't cache it in memory first before writing?!

Cheers,
Devan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File Upload Tracking
« Reply #3 on: July 24, 2008, 02:53:55 AM »
ha - yeah, you got it in 1, the whole Post arrives before it even thinks about starting to process it...

So it's not as simple as just looking at a file.

Cheers
Bruce