Page 1 of 1

CURL - Posting Data to page....

Posted: Wed Jun 07, 2006 10:05 pm
by tecktalkcm0391
I have this HTML Code:

Code: Select all

<form action="http://s81.photobucket.com/albums/j224/****/" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <span class="panelUpload panelHalfWidth">
  <input type="hidden" name="addtype" id="img_addtype" value="local" />
  <input type="hidden" name="multi" id="img_multi" value="1" />
  <input type="hidden" name="listValidImageFiles" id="listValidImageFiles" value="gif, jpg, jpeg, png, bmp, swf" />
  <input type="hidden" name="media" value="image" />
  <!-- value(s): image|video -->
  <input type="hidden" name="action" value="addpic" />
  <label class="ltbluelabel"></label>
  </span>
  <p><span class="panelUpload panelHalfWidth"> </span><span class="visiblePanel">
    <input type="file" name="the_file[]" id="the_file1" size="30" class="floated" />
  </span></p>
  <p><span class="panelUpload panelHalfWidth">
    <input type="checkbox" name="preserve" id="preserve_img" value="true" checked="checked" />
  </span>Keep Name </p>
  <p>
    <label for="Submit"></label>
    <input type="submit" name="submitImgUpload" value="Submit" id="Submit">
  </p>
</form>

How can I make it submit the data, which is all in the PHP code, to the same page, but not having the user do anything?

If someone could help me or point me in the right direction, that would be awsome. All I have so far is:

Code: Select all

$post_data = $temp2;
			   
			  
			
			   $ch = curl_init();
			   curl_setopt($ch, CURLOPT_URL, "http://s81.photobucket.com/albums/j224/***/" ); 
			   curl_setopt($ch, CURLOPT_POST, 1 );
			   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
			   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			   $postResult = curl_exec($ch);
			
			   if (curl_errno($ch)) {
				   print curl_error($ch);
			   }
			   curl_close($ch);

Re: CURL - Posting Data to page....

Posted: Wed Jun 07, 2006 10:40 pm
by PrObLeM
you have to put all of the forum data into a string that looks like a qurey string ie.

$post_data = "var1=val1&var2=val2...etc";

Posted: Wed Jun 07, 2006 10:46 pm
by tecktalkcm0391
so i just need to do something like a urlencode does for the string of vairables?

Posted: Wed Jun 07, 2006 10:54 pm
by PrObLeM
tecktalkcm0391 wrote:so i just need to do something like a urlencode does for the string of vairables?
yea, sure