Octopress 部落格

一個靜態網站的部落格框架

PHP: Curl POST a File

I’m trying to post a
word doc file to a remote server using cURL. I’ve tried posting ot to a local folder (code attached) but I don’t get the file at the recieved page. All the FILES data is there but what use is a local path to a remote server?

Array
(
[file] => Array
(
[name] => php1431.tmp
[type] => application/octet-stream
[tmp_name] => C:\WINDOWS\TEMP\php1432.tmp
[error] => 0
[size] => 26112
)

)

”@$fullfilepath”
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $upload_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch);
curl_close($ch);

//echo $response;
}

?>


<form enctype=”multipart/form-data” action=”<?=$_SERVER[‘SCRIPT_NAME’]?>” method=”POST”>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”100000” />
Choose a file to upload: <input name=”userfile” type=”file” /><br />
<input type=”submit” value=”Upload File” />
</form>