Форуми / Craftwork / Server-side / Sending a PHP generated image as multipart/form data

GHengeveld
#10019 15.03.2009 06:13
I've made a script that uses cURL that does what I want. The fact that it uses cURL is not a problem, because the employer of my project, namely Hyves.nl uses cURL to process my upload. Like this:
"curl http://".escapeshellarg($oXml->ip)."/upload?token=
".escapeshellarg(urlencode($oXml->token))." -F 
file=@".escapeshellarg($filename)." -F 
title=".escapeshellarg($title)."
-Fsubmit=Verstuur"
The final script will likely (depending on success of the project) be hosted on the same servers (a cluster of about 1500 servers actually), so cURL is definately supported.
My current testing script looks like this:
<?php
$ch = curl_init("http://somesite.com/upload.php"); // Link to upload script
curl_setopt($ch, CURLOPT_POST, true); // Set method to POST
curl_setopt($ch, CURLOPT_POSTFIELDS, array('uploaded'=>"@005.jpg")); // Form fields are passed in the array, form data is prefixed with @
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_exec($ch);
curl_close($ch);
?>

For more information read the Hyves API MediaUpload documentation (english).

Відредаговано: Koradhil (15.03.2009 07:09, 15 років тому)