我有以下脚本
<?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!";
}
?>
我喜欢修改它,文件上传到服务器A,服务器A上的脚本调用这个脚本,你可以在这里看到,在服务器B上,因为我不能直接调用这个脚本。
这怎么可能?在服务器 B 上,很明显,我会使用顶级脚本。但我必须考虑服务器 A 上的脚本。
我想我必须使用函数从服务器 A 调用服务器 B 上的脚本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
?>
但是如何使用file_get_contents()
或其他任何方法解析 Post-File?