tags:

views:

212

answers:

4

Hi, here is my situation:

I want to create an AJAX file-upload script, which will upload to an external site (ie: not the one the script is located in) and at the same time report the progress of the upload. How would I go about doing this? Note that the process must be secure.

A: 

There are two ways to do:

The advantage of the flash method is that it does not require you to rewrite any server side scripts. This is especially good if you upload to a different server than yours. You do need to put a cross domain xml file on that server though.

The advantage of the ajax version is that it does not require your users to have flash installed.

Marius
A: 

If you are POSTing the file to another server there is no way to know the status of this upload since the upload is done between the users browser and the remote site.

If you have access to the script that handles file upload on the other site you could use Zend_File_Transfer and Zend_ProgressBar to fetch the information on the uplad progress from the other site and display it on your page.

Note: to use Zend_ProgressBar you need APC or uploadprogress extension.

Goran Jurić
I've read somewhere else that this is possible with APC installed. Are you familiar with this?
Nikko
Not without having a script on the external server. This script could then access information about the upload progress which is stored in APC.As I wrote, you need either APC or uploadprogress extension installed on the _external_ site for Zend_File_Transfer to be able to report the upload progress.
Goran Jurić
A: 

There is no way to get the exact progress using ajax and php. Using php and ajax you can only know wheather the upload is in progress or finished. That is the reason why all ajax/php aplications have loading but no progress bar. If you explicitly want progress bar you should use a PERL CGI

Teo
A: 

Flash ( swfupload ) is probably the easiest. Vimeo.com uses swfupload to achieve this as well. Ihe only other method I know of involves php and APC which a tutorial of can be found at http://phpriot.com/articles/php-ajax-file-uploads.

namelessnotion