11

Possible Duplicate:
Upload Progress Bar in PHP

Can anyone suggest a good and easy way to include the file upload progress bar, while uploading a file. I know it would be a mix of javascript & php. Please suggest one

Community
  • 1
  • 1
Rahul TS
  • 1,208
  • 7
  • 26
  • 53
  • I have often wondered this. I have always used a Flash solution before like Uploadify. I have tried with jQuery, but it failed when trying to use two Ajax requests. I have found Flash solutions unreliable though, especially in IE. No surprise there. – Jake N Aug 31 '10 at 19:52
  • Forget about javascript for that. Flash is unfortunatelly the ideal solution for now – Iznogood Aug 31 '10 at 19:53
  • 1
    This question has already been asked a few times: http://stackoverflow.com/questions/849237/upload-progress-bar-in-php http://stackoverflow.com/questions/653063/upload-progress-using-pure-php-ajax – bjudson Aug 31 '10 at 19:58

6 Answers6

1

I like uploadify. Its very easy to implement and does the job perfectly.

Iznogood
  • 12,447
  • 3
  • 26
  • 44
  • yes I like the uploadify and currently using it for showing the upload progress. Its a good and neat one. I am trying it another way so that I can simply do the job with less files and more control over the design as I am not so fit with the swf flash stuffs. Also I have a doubt whether I can do the video encoding while uploading the video files through uploadify with ffmpeg – Rahul TS Aug 31 '10 at 20:07
  • Sure you can. Once the file is on the server it changes nothing how it got there. And javascript solutions would have to be tested on internet explorer. Good luck with that. :) – Iznogood Aug 31 '10 at 20:26
  • thanks, have you had an idea of sample encoding technique other than ffmpeg to convert the video files into .flv .mp4 and .avi format. Cause the current hosting account of mine is not supporting the ffmpeg format – Rahul TS Sep 01 '10 at 05:24
  • NOthing except using something like esternal services that do this for you. Even store the videos. Amazon S3 comes to mind. – Iznogood Sep 01 '10 at 05:42
1

http://valums.com/ajax-upload/

I chanced upon this recently and really liked it.

Alec Smart
  • 94,115
  • 39
  • 120
  • 184
0

SWFUpload

SWFUpload is a JavaScript Library that wraps the Flash Player's upload function. It brings your uploads to the next level with Multiple File Selection, Upload Progress and Client-side File Size Checking.

Bob Fanger
  • 28,949
  • 7
  • 62
  • 78
  • Well... not really: It works differently from a normal form-based file upload. You can't just put it into a normal file upload form and show a progress bar, which I think the OP is looking for. (If not, SWFUpload is a great choice!) – Pekka Aug 31 '10 at 19:59
  • yes I am, but I also want this simple form with progress bar after upload it will encode the content to other formats like .flv .mp4 & .avi as I want this form to upload video – Rahul TS Sep 01 '10 at 05:26
  • the swf upload is great but I dont go so deep as you said it may not be usefull in this specific case of encodeing video file after uploading – Rahul TS Sep 01 '10 at 05:27
0

You'll have to check the size of the part of the file wich is allready on the Server, then get it on the Client per Ajax where you can paint the progress bar. (Remember to check the size of the hole Data before, to calculate the percantage ;-) )

Tokk
  • 4,499
  • 2
  • 31
  • 47
  • 1
    So... you have to upload the file in order to know its size, and then jump back in time to show the progress bar? :) – Pekka Aug 31 '10 at 19:57
  • right :-D No, you could read the filesize in the browser per JS bevore the upload... – Tokk Aug 31 '10 at 20:01
  • that is not possible. There is no access to local files from JavaScript. – Pekka Sep 01 '10 at 08:18
  • @Pekka It is possible in more modern browsers: https://developer.mozilla.org/en/Using_files_from_web_applications#Getting_information_about_selected_files – John Stimac May 27 '12 at 05:47
0

I don't believe this is possible utilizing ajax. The only time you can get the complete file size is after upload and by then it's too late. '

If you utilize a flash-based uploader however, it is possible.

Angelo R.
  • 2,285
  • 1
  • 17
  • 22
0

all "ajaxy" looking solutions use an swf object to do the upload job. you can home-cook your progressbar if you have an op-code cacher like APC

Here is Martin Jansen blogging about Rasmus Lerdorf's simple upload code which in the end uses APC

http://martinjansen.com/2007/04/28/file-upload-progress-bars-with-php/

and a working example

kali
  • 1,143
  • 1
  • 9
  • 26