//索引文件
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php'
//上传文件
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="image"/>
<input type="submit" value="Post"/>
</form>
<?php
if(isset($_FILES['image']['tmp_name'])){
$ch = curl_init();
$cfile =new CURLFile($_FILES['image']['tmp_name'],$_FILES['image']['type'],$_FILES['image']['name']);
$data = array('myimage' => $cfile);
curl_setopt($ch,CURLOPT_URL,"http://localhost/curl/send_file_to_server/uploads.php");
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$response = curl_exec($ch);
if($response == true){
echo "File Posted";
}
else{
echo "Error: ".curl_error($ch);
}
}
?>
在这里,我要将index.php的图像存储到uploads.php中。我正在使用php的curl方法。该文件打印了该文件,但未存储在上载文件夹中。