I need to somehow integrate off-site uploading onto my website, that is, so the uploading form itself is on my website but the file gets uploaded to a server somewhere else.
I have experience in PHP file uploading and handling, but the files were all being transferred to the machine that held the form. This time I need it to upload directly to a different server.
One way I thought was something like this:
<form action="http://somewhere-else.com/upload.php" enctype="multipart/form-data">
<input type="file" name="theFile" />
<input type="submit" value="Upload File" />
</form>
But I'm not sure if that would really work out, would the bandwidth required for uploading the file be used on both the server that handles the page with the form, and the destination upload server? Another way was with iframes, as in have a complete iframe coming from one of the upload servers, but开发者_如何学C this just seems hacky to me.
Does anyone have any experience in this area that they can use to enlighten me? I would prefer a solution in PHP, if possible.
Cheers.
On your example the form on the "other" server handles the upload. So any bandiwth and space requirements consideration are for that server. Of course this assumes you have some control over that server.
It depends on what you're looking to achieve. Is it to save bandwidth on one of your servers? Is it that you simply want uploads stored somewhere else?
Wherever the form address points to, that will take the bandwidth hit for uploading the file.
If you want to keep users on your website throughout the form submission, you can either take the iframe approach, or use PHP socket functions for uploading files via FTP (a quick Google got me this PHP FTP example).
精彩评论