PDA

View Full Version : How would i make it upload to another sever



GoldenMerc
23-05-2009, 10:17 AM
Well say i had the upload page on sever 1, but i want the images to go to sever 2, how would i go about doing this?
+rep 5 times kk :D

hamheyelliot
23-05-2009, 10:24 AM
Usually I suppose you would have to point the upload form to the PHP File on the other server, ensuring the folder you want the files to go into have the correct permissions.

GoldenMerc
23-05-2009, 10:28 AM
the upload form has to be on sever 1.

Excellent2
23-05-2009, 10:39 AM
Why don't you have the upload on server 1 upload images to a folder on server 1. Then on server 2 use file_get_contents() to grab the images or files from that particular folder?

GoldenMerc
23-05-2009, 10:41 AM
Thats a fairly gooooood idea actually, Would it be easy to code dya think?
Ross

Excellent2
23-05-2009, 10:48 AM
Thats a fairly gooooood idea actually, Would it be easy to code dya think?
RossShouldn't be too hard. Or of course you can just have something like this:

Server 1:

<form method="post" action="www.server2.com/upload.php" enctype="multipart/form-data" />
<input type="file" name="file" />
<input type="submit" name="submit" value="Upload" />
</form>
Server 2:

<?php
// handles all data from server 1 and uploads it to server 2
?>

GoldenMerc
23-05-2009, 10:51 AM
hmm, nah i think your first idea was fairly decent...

Excellent2
23-05-2009, 10:57 AM
hmm, nah i think your first idea was fairly decent...Sounds good.

Just use file_get_contents() to read the folder.

GoldenMerc
23-05-2009, 11:02 AM
Right now im confused, would file_get_contents() go in the folder where i want the images to go in? what would i name that file too n the coding in that file?
Ross

Excellent2
23-05-2009, 01:28 PM
Basically you'd do something like this. Somebody correct me if I am wrong.



<?php

$file = "index.php";

$files = file_get_contents('url');

file_put_contents($file, $files);

?>


Now I'm not sure if that works but yeah, try.

Source
23-05-2009, 03:26 PM
Normally you would do it by having the upload form and upload handler on server A and an API type handler on B. You would then use CURL on server A to post the data to server B handler, of which would then store the files.

http://forums.devshed.com/php-development-5/php-curl-send-a-file-533233.html

that might help with curl a bit, of course you can use php.net/curl

Blob
23-05-2009, 09:34 PM
Temp store the images on server A after an upload and add the name to a txt file then put a cron job on server B to download that txt file and copy all the images, then make server B make a txt file with the files its download then a cron job like an hour later to check that txt file and delete the old text file and the images in that txt file.

Excellent2
23-05-2009, 09:58 PM
You COULD do it via connecting to an FTP, I think.

Blob
23-05-2009, 10:01 PM
You COULD do it via connecting to an FTP, I think.

http://www.web-development-blog.com/archives/tutorial-ftp-upload-via-curl/

you are correct.

Want to hide these adverts? Register an account for free!