tags:

views:

116

answers:

3

I have a scenario where I have a page on one server which prompts a user to upload a file. I need this file to be uploaded to a different server with a larger storage facility. I then need to get the absolute path of where the file now resides on the server sent back to the originating page.

The file size that will be around 15mb, so they aren't small files, and I'd like to avoid double uploading if possible (uploading to the server, then pushing over to remote server).

Any direction on this is appreciated.

+2  A: 

If the remote server is also running as a web server you could create the upload form and have the submit action go to the other server. The disadvantage of this is that some browsers will treat this as a potential security hole and warn the user when the page is displayed, but you can get around this by creating a reverse proxy entry in your main web server that points to the file server.

alxp
Given the large file size is there anyway to give the user feedback mid-upload via a progress bar? Or is a spinning loading GIF the best I'm going to get?
BlueVoid
The simplest way to have a progress bar is using a flash based uploader. like jcUpload or swfUpload.
Hubert Perron
There is no flash-free alternative?
BlueVoid
There's a way to do it with Jquery http://t.wits.sg/2008/06/25/howto-php-and-jquery-upload-progress-bar/
alxp
The advantage of a flash based upload is that the server side code do not change, it stay the same as you were uploading via a normal <input type=file /> tag. Gmail use flash based upload for attached files.
Hubert Perron
I went with swfUpload and its working perfectly. Thanks!
BlueVoid
A: 

If the second server can be accessible from the web then just make the html form post to the storage server then redirect to the first web server. During the redirect you could pass back additional variables via the GET query string.

Hubert Perron
+2  A: 

You could upload the file directly to the storage server, specifying a unique key in the hidden form like:

<form action="http://mystorage.com/upload" method="post">
    <input type="file" name="myfile" />
    <input type="hidden" name="key" value="asdf1234sadfasfd34565xx" />
</form>

Then simply send a RESTful request from the storage server to your primary server, stating the unique key and the absolute path... or fetch the absolute path by "asking" your storage server when the primary server needs to know the file location... limitless possibilities ahead!

Steffen Müller