I'm trying to create a custom ajax upload for a project .
therefore dont want to use some open source scripts/codes.
So Here's the situation
im trying to get upload size of the file using jquery ajax while the file is uploading by fetching file size of the file from a php file.
So i'll use .delay() to repeat process after a certain interval and '$_FILES['file'] ['tmp_name'] ' to fetch its name and size etc ..
can any body help me on how to do this ???
im a bit confused ..
Asked
Active
Viewed 808 times
0

cuerere
- 1
-
This makes no sense: The $_FILES array will be populated before the PHP script starts running. What exactly do you want to do? – Unicron Mar 19 '11 at 20:53
-
why do you need filesize on the client side? – Your Common Sense Mar 19 '11 at 20:53
-
To show that 'x' amount is upload out of 'xx' amount – cuerere Mar 19 '11 at 20:55
-
I want to fetch the size of the file while uploading – cuerere Mar 19 '11 at 20:56
-
Already awnsered here https://stackoverflow.com/questions/4455282/call-a-javascript-function-at-a-specific-time-of-day – R-son Oct 19 '20 at 15:08
1 Answers
1
With a standard install of PHP, you will not be able to track the upload of a file : once the upload is complete, you'll be able to work with $_FILES
; but not as long as the upload is in progress.
If you want to keep track of the progress of an upload, you'll have to either :
- Install the APC extension, and configure
apc.rfc1867
(there are a bit more informations on that page) - Install the uploadprogress extension, which has been created to do just that.
Here are a couple of articles that might give you some pointers :
- APC : Monitoring File Uploads using Ajax and PHP
- Upload Progress Meter - Common issues and some answers
- Upload Progress Meter extension for PHP 5.2
- AJAX File upload Progress and PHP AJAX File Upload Progress Meter Updates
From what I recall, when it comes to tracking files uploads, the second solution might be a better choice -- if I'm not mistaken, APC stores more stuff in RAM, which could cause some problems.
And here's a question+answer about that specific matter : APC vs pecl uploadprogress

Community
- 1
- 1

Pascal MARTIN
- 395,085
- 80
- 655
- 663
-
-
With PHP 5.2 and PHP 5.3, no, that's not something that can be done using PHP itself *(not adding any extension, I mean)* ;;; With the next version of PHP *(might be called 5.4, maybe)*, it might be possible, see http://schlueters.de/blog/archives/151-Upload-Progress-in-PHP-trunk.html – Pascal MARTIN Mar 19 '11 at 21:01