How can i redirect a php upload to another server?
Hello fellow sitepoint users,
i have an academic project that consists on a simple file hosting service that is currently running on a shared hosting account. i use swfupload and php as my upload method and ATM in storing the files in the shared account.
Since the TOS of that hosting service forbids the use of shared accounts for that purpose, even only being an academic project, i was thinking on using CloudFiles from Mosso for the storage of the user uploaded files.
My question is, how can i redirect the upload of the file directly to CloudFiles without any data from the file being sent to the shared account?
My understanding is that if i use the php method for the upload of the file the file first goes to the shared account's server and only after that is sent to Cloud Files.
Am i correct? Is there any way to bypass the shared account's server?
Last edited by NetCrasher; May 3, 2009 at 12:26.
Reason: Typo on the title
Yes you are correct, even if you do a redirect, the file will still be sent to the shared account's server to start with.
You'd have to set the action on the upload form to a location on the other server if you don't want the file to be uploaded to the shared hosting account. You could then redirect back to a "file uploaded" type page (or similar) on the shared account once the file is uploaded.
There are numerous scripts/classes available via google search that show how to ftp a file upload to another server. The file upload never needs to be stored on the primary server, and most developers would never allow it to be stored there, due to security precautions.
i'm sorry, but think you didn't understand my question.
cloud files api works kinda like the php file methods, open, write, close.
my problem is that when you upload the file to a server through a form it is handled in php through the $_FILES array, the problem is that if i try to redirect that to cloud files the first data is always sent to my shared account server because my php script is receiving the data from the user and writing the data to cloud files.
the only way i see to solve that problem is to use client side scripts so that the data is sent directly from the user to cloud files instead of hoping through my server if i use a server-side script.
ftp isn't possible because cloudfiles doesn't accept ftp connections, either way if i'd use an ftp connection, that connection would be made by my server and not by my user if i use a server side script