Programming

  • 1 {{ upvoteCount | shortNum }}

    File upload using curl. What to do when name of input field

    firefly in Programming

    Hi, This is the code I made to show the problem: PHP Code: $useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729)";$timeout = 10 ;$cookie = tempnam ("/tmp", "CURLCOOKIE");  $post = array('_method'=>"put",                     'authenticity_token'=>'zcvcxfsdfvxcv',                     'profile_image[a]'=>"@Girl-Next-Door-movie-f01.jpg"                      );                $ch = curl_init();        curl_setopt( $ch, CURLOPT_USERAGENT, $useragent);        curl_setopt($ch, CURLOPT_HEADER, 1);        curl_setopt($ch, CURLOPT_POST, 1);         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));        curl_setopt($ch, CURLOPT_URL, "localhost/test.php");         curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);        curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie );        curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );        curl_setopt( $ch, CURLOPT_ENCODING, "" );         curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );        curl_setopt( $ch, CURLOPT_AUTOREFERER, true );        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );    # required for https urls        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );         curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);        $html = curl_exec($ch);        curl_close($ch);  Now this link used above: localhost/test.php has this code: PHP Code:     print_r($_POST);    print_r($_FILES);  It simply prints whats ... [read more]