我有以下脚本
<?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上的脚本。
我想我必须使用函数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?
答案 0 :(得分:0)
您无法从其他服务器获取代码文件。可能你必须改变逻辑并使用ajax。