How to forward the post file to an other server to the same script
I have the following script
<?php
$target_path = $_SERVER[DOCUMENT_ROOT]."/files/cache/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name'])." has
been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
I like to modify it so, that the file is uploaded on server A and the
script on Server A calls this script, you can see here, on server B,
because I can't call this script directly.
How can this look like? On Server B, it's clear, I would use the top
script. But I have to think about the script on server A.
I think I have to call the script on server B from server A with the
function file_get_contents(...)
<?php
$target_path = $_SERVER[DOCUMENT_ROOT]."/files/cache/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name'])." has
been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
//Start upload to server B
file_get_contents("http://server2.com/upload.php");
//...
//But here I have to add the post data-File
?>
But how to parse the Post-File using file_get_contents() or anything else?
No comments:
Post a Comment