0
I'm transferring files from an existing http request using cURL like so...
$postargs = array(
'nonfilefield' =>'nonfilevalue',
'fileentry' => '@'.$_FILES['thefile']['tmp_name'][0]
);
$ch = curl_init('http://localhost/curl/rec.php');
curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_POST,TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postargs);
curl_exec($ch);
curl_close($ch);
我能得到這個工作的唯一方法是使用tmp_name,沒有它將不會發送。然而,當我想稍後命名文件時,我將失去名稱值。使用cURL保存文件的名稱以傳輸文件
有沒有辦法做到這一點,保留$ _FILES數組,因爲它通常不捲曲?我還在我的腳本中使用了一系列文件字段,因此目前我必須將我的多維數組轉換爲單個維才能運行。