LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-12-2005, 12:53 PM   #1
Cupacabra
LQ Newbie
 
Registered: Sep 2004
Posts: 5

Rep: Reputation: 0
file upload with php+libcurl via POST


I am trying to upload a file from my webserver to a remote server via a POST form. The problem is that the postData appears to get dropped by libCurl. It is sending headers with a content length of 0. I have tried using a string instead of an array, but the file is not passed just the path to it.

PHP Code:
$postData = array();
//simulates <input type="file" name="file_name">
$postData'submit' ] = "Upload";
$postData'var1' ] = "1048576";
$postData['var2'] = $var2;
$postData['var3'] = $var3;
$postData['var4'] = $var4;
$postData'file' ] = "@$file";
$url "path.to/upload.form";
$ch curl_init();
curl_setopt($chCURLOPT_URL$url );
curl_setopt($chCURLOPT_RETURNTRANSFER,1);
curl_setopt($chCURLOPT_POST);
curl_setopt($chCURLOPT_POSTFIELDS$postData);
curl_setopt($chCURLOPT_VERBOSETRUE);
curl_setopt($chCURLOPT_HEADERFALSE);
//curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041214 Firefox/1.0");
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
curl_setopt($chCURLOPT_SSL_VERIFYHOSTFALSE);
curl_setopt($chCURLOPT_SSL_VERIFYPEERFALSE);
curl_setopt($chCURLOPT_COOKIE$cookie);
curl_setopt($chCURLOPT_REFERER"path.to/upload.form");
$rtnValue curl_exec($ch);
curl_close($ch); 
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP upload file to other server antony_csf Programming 13 02-04-2005 03:11 AM
Cant upload a file bigger then 1mb with php OrangeLefty Programming 1 04-19-2004 01:54 AM
PHP: upload file to client... ugenn Programming 3 08-26-2002 10:59 AM
File upload via PHP saravanan1979 Programming 1 02-14-2002 04:28 AM
File upload via PHP!!! saravanan1979 Programming 0 02-14-2002 01:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration