0

Possible Duplicate:
Upload Progress Bar in PHP

guys, i need some help with this problem

I'm doing a file upload process where the source file is transfered to the server and then the data from it is inserted in to database.

i need to display progress bar which shows the progress from the time of file uploading to server till data inserted into the database from that uploaded file.

i find files uploading progress bar only for files uploading to server and progress bar not till data insertion.

thanks in advance !

Community
  • 1
  • 1
dinesh
  • 342
  • 2
  • 13
  • Since Apache does not pass the request to the PHP interpreter until the entire request is received, how would PHP code know anything about the status of the upload? – Dan Grossman Feb 05 '11 at 17:20
  • Possible duplicate: http://stackoverflow.com/questions/849237 – Jonah Feb 05 '11 at 17:21

4 Answers4

1

Okay, so to write a progress bar you need to know what 100% of the file-size are. To know the file-size on server-side (with PHP which runs server-side), you first have to receive the whole file. But after receiving the file, it doesn't help you anymore, because then the upload would be finished.

Progress-Bars on file-uploads are often done with Flash, as you can detect the file-size client-side with ActionScript (Flash's scripting language).

anroesti
  • 11,053
  • 3
  • 22
  • 33
1

You can't do that with PHP. PHP is server side language. Better way to do that is to use a jquery and animate it.

Filip Krstic
  • 713
  • 7
  • 19
1

There is no way to do this with PHP. I'd use Uploadify.

Chris Laplante
  • 29,338
  • 17
  • 103
  • 134
0

To measure the progress of the SQL queryes, you can do the following:

  • After uploading the file you can run some regexp on it to detrmine how many queries you'll have to run
  • You can then register a counter in SESSION or similar where you know how many queries you have run
  • Have an AJAX script call a PHP script that gives you the total number of queries and how many of them were executed.

There are some problems though. I don't know what kind of data format you have for the file, so I presumed that it's something that can be transformed in queries. Also, it might be faster run a single query instead of hundreads (for INSERT for example)

Interfector
  • 1,868
  • 1
  • 23
  • 43