可能重复:
Failing to upload file with curl in heroku php app文件上传到超薄框架在PHP中使用卷曲
处理PHP中的文件上传,我想使用该文件卷曲发到我的休息后, api使用Slim Framework。但是,$ _FILES在到达Slim中的函数后总是空的。
sender.php
if(move_uploaded_file($_FILES['myFile']["tmp_name"], $UploadDirectory . $_FILES['myFile']["name"]))
{
$ch = curl_init();
$data = array('name' => 'test', 'file' => $UploadDirectory . $_FILES['myFile']["name"]);
curl_setopt($ch, CURLOPT_URL, 'http://localhost/slimlocation/upload/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
}
和函数接收的修身要求:
$app->post('/upload/', function() use ($app) {
if(isset($_FILES)){
// count is always zero
echo count($_FILES);
}
});
我是否发送错误的文件和/或是否有可能做什么,我尝试?任何帮助表示赞赏。
非常感谢。我不需要CURLOPT_UPLOAD,但文件名/完整路径是我的问题。 – Drew