//name: test.php ......................................//Здесь авторизация $upload = 'book.htm'; $data = array("token" => $token[1], "name" => 'bookFile',// 'upload' => "@".$upload, "visibility" => "openned", "show" => "1", "go_save" => "Послать"); $result=post("http://xxx.net/add_up.php",$data,$referer,$ua); echo $result;
<form enctype="multipart/form-data" action="" method="post"> <input type="hidden" name="token" value="XXXXXXXXX" /> <input type="file" name="bookFile" size="44" class="text" /> <input name="visibility" value="openned"/> <input name="show" value="1"/> <input type="submit" name="go_save" value="Послать" /> </form>
function post($url,$post,$refer,$ua) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERAGENT, $ua); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_REFERER, $refer); curl_setopt($ch, CURLOPT_COOKIEJAR, "./cook"); curl_setopt($ch, CURLOPT_COOKIEFILE, "./cook"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); return $result; }