Jump to content

Using CURL to submit files


PyraX

Recommended Posts

Hi,

 

Im looking for a solution for that will allow me to submit a form on a remote website that will send a file. The only think i know of that can do this is curl.

 

I also need to grab the randomised image from the first site and submit the verification text.

 

Thanks in advance.

 

PyraX

Link to comment
https://forums.phpfreaks.com/topic/65773-using-curl-to-submit-files/
Share on other sites

I also need to grab the randomised image from the first site and submit the verification text.

 

So you're trying to bypass a captcha type authentication? Good luck. I think you'll need it. The whole point of these image verifications is to prevent any automated, computer use of the form.

captcha code:

<?php

/*********** POST DATA USING CURL **************/
//parameters for posting data
$data = array('var1' => 5,"var2"=>10);

// CURL Session initialization
$ch = curl_init();

//CURL Option settings
curl_setopt($ch, CURLOPT_URL,'http://localhost:9000/test/curl/post_action.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//execution and posting data
$res=curl_exec($ch);
/*********** CAPTCHA CODE **************/
$str = "";
$length = 0;
for ($i = 0; $i < 4; $i++) {
$str .= chr(rand(97, 122));
}
$imgX = 60;
$imgY = 20;
$image = imagecreatetruecolor(60, 20);

$backgr_col = imagecolorallocate($image, 238,239,239);
$border_col = imagecolorallocate($image, 208,208,208);
$text_col = imagecolorallocate($image, 46,60,31);

imagefilledrectangle($image, 0, 0, 60, 20, $backgr_col);
imagerectangle($image, 0, 0, 59, 19, $border_col);

$font = "VeraSe.ttf"; // it's a Bitstream font check www.gnome.org for more
$font_size = 10;
$angle = 0;
$box = imagettfbbox($font_size, $angle, $font, $_SESSION['rand_code']);
$x = (int)($imgX - $box[4]) / 2;
$y = (int)($imgY - $box[5]) / 2;
//imagettftext($image, $font_size, $angle, $x, $y, $text_col, $font, $_SESSION['rand_code']);
imagettftext($image, $font_size, $angle, $x, $y, $text_col, $font, $str);

header("Content-type: image/png");
imagepng($image);
imagedestroy ($image);
?>

 

Regards,

Vijay

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.