awi Posted October 30, 2007 Share Posted October 30, 2007 Hi again, I posted a msg earlier regarding the same problem but this time I'm going to try CURL instead of fsockopen (giving up for now). Ok, so I'm trying to POST some data including a file (as if you are sending a multi-part html form) using curl. Here is what I'm trying to run: $fileToSend = join("", file($file)); // $file is name of file and it resides in same dir as this script $postfields = array( 'clip.category' => $someCatId, 'clip.tags' => $someTag, 'clip.title' => $title, 'clip.description' => $desc, 'clip.language' => 'en', 'clip.file' => "@$fileToSend"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $res); curl_setopt($ch, CURLOPT_FAILONERROR, 1); //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "$postfields"); // execute curl command $result = curl_exec($ch); print '<pre>'; print_r($result); exit; My $result is empty, I get a blank page. 1) Do you see anything wrong with my code? 2) I do not have access to the "receving" end of this. How ould you diagnose problems without that kind of access. Thanks again for your help CA Link to comment https://forums.phpfreaks.com/topic/75357-sending-a-post-with-a-file-using-curl/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.