cURL Upload Help


Posted on 16th Feb 2014 07:03 pm by admin

OK, I am creating a bridge from a local program to my website and I am trying to find the best way to upload the client file from the local program (which is a CSV file) to my server. I was thinking I could use cURL to accomplish this feat. Basically the local program will invoke a batch file that opens my site with the path of the local file (which is the same file name and path everytime), then use cURL to upload that file to my server to be parsed and input into the database. Can this be done?
If so, I would have to just point the cURL to the .php file that would accept the uploaded file correct? And could I use POST for this with multi-form data and not PUT? Any input on this would be great, thanks.
Maybe something similar to this...
Code: $file='testWordDoc.doc';

echo $file;

$ch = curl_init('http://myurl.com/recieve_posted.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file'=>"@$file",'testkey'=>'test value'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);
curl_close($ch);
print "$postResult";

No comments posted yet

Your Answer:

Login to answer
223 Like 45 Dislike
Previous forums Next forums
Other forums

php code to accept and delete incoming data
Using following HTML Code please show me how to write PHP code to accept and delete the incoming dat

Can't get the unicode character
I'm trying to get some text from various parts of a file. I have converted the file to hex (bin2hex)

Help with echo()
I'm having some problems with this code:

Code: echo '
<A HREF="jav

Implementing Single Sign-On using SAML 1.1, x.509, LDAP in C#.net
Hi, I got a requirement from the client i.e implementing single sing on using SAML 1.1( LDAP &

need help in mysql_num_rows()
please tell me what i am doing wrong in this query. it displays this error

Code: Warning: mys

need help with mail()
hi i want to send an email with attaching pdf file using php. i have the following script but the pr

Database 'Validation'
Hi everyone,
I'm trying to validate the password entered by the user with the password in the dat

RadioButtonList data selection
view plaincopy to clipboardprint?

foreach result into a single variable
Hi,

I have this code...

Code: [Select]foreach ($_POST['Interests'] as $interest =&

Help with usergroups? prolly really quick
So were coding our own forums for a game system we made an we have the users level setup but now I n

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash