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 ne开发者_运维问答ed 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 !
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).
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.
There is no way to do this with PHP. I'd use Uploadify.
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)
精彩评论