试试这个解决方案:
# Source domain code..
$save_dir = 'C:\inetpub\vhosts\abc.com\upload\abc.jpg' ;# Temporary save file in your source domain..
$url = "http://www.def.com/copy_upload_file.php"; # destination domain URL
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
$post = array(
"file"=> "@".$save_dir,
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
将此文件添加到您的另一个域中..
# Destination domain file called as copy_upload_file.php
$path = 'C:\inetpub\vhosts\def.com\upload\'; # Write full path here
if(isset($_FILES["file"]))
{
if ($_FILES["file"]["error"] > 0)
{
echo "0";
}
else
{
if(is_uploaded_file($_FILES["file"]["tmp_name"]) && move_uploaded_file($_FILES["file"]["tmp_name"], $path . $_FILES["file"]["name"]))
{
echo "1";
}
else {
echo "0";
}
}
}
else
{
echo "0";
}