Jump to content

Recommended Posts

Hello, i wish to process a form automatically using curl. I have tried a few tutorials, but to no avail, any help would be great.

 

The form code is below.

 

<form action="http://heywatch.com/upload" enctype="multipart/form-data" method="post" >
  <input type="hidden" value="f60d0e2674709ce68f597ce89ded1bb0" name="key" />
  <input type="hidden" value="http://yoursite.com/upload_success.php" name="redirect_if_success" />
  <input type="hidden" value="http://yoursite.com/upload_error.php" name="redirect_if_error" />
  <input type="hidden" value="20" name="your_site_user_id" />
  <input type="hidden" value="1540" name="post_id" />
  <p><input id="data" name="data" type="file" /></p>
  <p><input name="commit" type="submit" value="Upload" /></p>
</form>

 

Thanks

 

nick

Link to comment
https://forums.phpfreaks.com/topic/50731-curl-help/
Share on other sites

It wouldn't be fair for us to "program" it for you.

http://www.google.com/search?hl=en&q=basic+curl+tutorial&btnG=Google+Search

Since you are looking for something pretty basic "with" curl. I can understand it can get frustrating dealing with, because there are hardly any tutorials out there for it.

I mean w3schools.com doesn't even have a part on that yet.

Look around for some tutorial's, work up a rough bit of code and then let us help you to make sense of it and make it work.

Link to comment
https://forums.phpfreaks.com/topic/50731-curl-help/#findComment-249398
Share on other sites

Right, this is what im using now.

 

$url = "http://heywatch.com/discover";
$ch = curl_init();    // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS,"url-field=$fileName&key=f60d0e2674709ce68f597ce89ded1bb0"); // add POST fields
$chresult = curl_exec($ch); // run the whole process
curl_close($ch); 
echo $chresult;

 

Basically, i am trying to get a file URL posted into this API.

The form i have posted above is for an upload, can a URL be put into an upload field form?!

 

Any help on this would be great!

 

Nick

 

 

Link to comment
https://forums.phpfreaks.com/topic/50731-curl-help/#findComment-249430
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.