Jump to content

libcurl file http post question


Wallboy

Recommended Posts

Hello, I'm wondering if it's possible to send a file through post using libcurl without having to use the browse button and manually selecting the file? And also would this only be possible if the file exists on the remote server, or is it possible to access a local drive to grab the file and upload temporarily and send over post? I'm trying to create a script that will automate a form with various text inputs and a I'm stuck on how with files.

 

How can I achieve this?

 

Thanks!

Link to comment
Share on other sites

so do you want the user to upload a file then the server does a cURL request and sends the file the user uploaded to another server?

you could do something like example 2 on http://php.net/manual/en/function.curl-setopt.php and change the array to

$data = array('file' => '@'. $_FILES['file_form_field_name']['tmp_name']);

this would upload the file straight from the tmp file that the file was first uploaded to when it was sent from the user to the first server the only problem is the server on the other end of the cURL transfer will get something like phpcpjNeQ as the file name with no ext. if you need a ext you could move the file the user uploaded to a random place then use it in the cURL transfer then delete it before the script ends

 

Scott.

Link to comment
Share on other sites

No, I have a form on MY server that contains text,file inputs. I'm making a script that can submit post values to the form php automatically where it currently gets values from a txt file such as the name and description and then grabs the next line in the txt with the new value and repeats. I was wondering if I would have to upload the files to my server first and then somehow use libcurl to read each of those files and include those in the loop. Or if it was even possible to grab the file on my local computer without using the windows browser(which I don't think is possible?)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.