curl上傳文件

<?phpphp

$curl_handle = curl_init ();curl

// Set default options.socket

curl_setopt ( $curl_handle, CURLOPT_URL, 'http://my.focus.cn/test/socket.php');url

curl_setopt ( $curl_handle, CURLOPT_FILETIME, true );xml

curl_setopt ( $curl_handle, CURLOPT_FRESH_CONNECT, false );ip



curl_setopt ( $curl_handle, CURLOPT_HEADER, true );it

curl_setopt ( $curl_handle, CURLOPT_RETURNTRANSFER, true );io

curl_setopt ( $curl_handle, CURLOPT_TIMEOUT, 5184000 );test

curl_setopt ( $curl_handle, CURLOPT_CONNECTTIMEOUT, 120 );file

curl_setopt ( $curl_handle, CURLOPT_NOSIGNAL, true );

curl_setopt ( $curl_handle, CURLOPT_HEADER, true );

//curl_setopt ( $curl_handle, CURLOPT_NOPROGRESS, false );

curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT' );

$aHeader[] = "Content-Type:text/xml;charset=UTF-8";

$aHeader[] = "x-bs-ad:private"; 

curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $aHeader);

$file = 'E:\soft\SSHSecureShellClient-3.2.9.zip';

$file_size = filesize($file);

$h = fopen($file,'r');

curl_setopt ( $curl_handle, CURLOPT_INFILESIZE, $file_size);

curl_setopt ( $curl_handle, CURLOPT_INFILE, $h);

curl_setopt ( $curl_handle, CURLOPT_UPLOAD, true );

$ret = curl_exec ( $curl_handle );

print_r($ret);

相關文章
相關標籤/搜索