curl上传文件

原创
2014/06/09 09:38
阅读数 584

<?php

$curl_handle = curl_init ();

// Set default options.

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

curl_setopt ( $curl_handle, CURLOPT_FILETIME, true );

curl_setopt ( $curl_handle, CURLOPT_FRESH_CONNECT, false );



curl_setopt ( $curl_handle, CURLOPT_HEADER, true );

curl_setopt ( $curl_handle, CURLOPT_RETURNTRANSFER, true );

curl_setopt ( $curl_handle, CURLOPT_TIMEOUT, 5184000 );

curl_setopt ( $curl_handle, CURLOPT_CONNECTTIMEOUT, 120 );

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);


展开阅读全文
打赏
0
3 收藏
分享
加载中
更多评论
打赏
0 评论
3 收藏
0
分享
返回顶部
顶部