我想從本地發送文件到遠程服務器,並將文件保存到服務器之後我想輸出響應。我正在使用cURL發送和上傳文件。當我在本地而不是遠程服務器上嘗試時,它正在工作。 我使用sftp協議和公共身份驗證密鑰進行連接。 我需要改變發送文件到服務器。php使用cURL將文件發送到遠程服務器
這是我的代碼。
$target_url = 'https://example.com/accept.php';
$file_name_with_full_path = realpath('ss.zip');
$post = array('file' => new CurlFile($file_name_with_full_path, 'application/zip' /* MIME-Type */, 'ss.zip'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;
以及最新的錯誤? – insider
沒有任何錯誤。它只是顯示空白頁面。 – Snappy
檢查日誌然後,空白頁是通常的錯誤500 – insider