[perl] LWP upload file

Discussion in 'PHP' started by maxfax, 29 Jul 2011.

  1. maxfax

    maxfax New Member

    Joined:
    23 Jun 2010
    Messages:
    25
    Likes Received:
    0
    Reputations:
    0
    Всем привет!

    Ниже приведен кусочек скрипты который отправляет данные методом POST как к ним подцепить файл ?
    Code:
    $res = $browser->post($url."file.php",['var'=>'value',],('User-Agent'=>'Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1'));
    
    ?
     
  2. dpe_x

    dpe_x Elder - Старейшина

    Joined:
    8 Sep 2010
    Messages:
    155
    Likes Received:
    35
    Reputations:
    14
    пример загрузки аватарки в моём мире..

    Code:
    my $page = $ua->post('http://foto.mail.ru/cgi-bin/photo/addphoto',
    	Content_Type => 'form-data' ,
    	Content => [ 'upload_avatar_from_my_alert' => 1 , 'addavatar' => 1 , 'add' => 1 , 'album' => '_myphoto' ,
    	'redir' => 'http://foto.mail.ru/cgi-bin/photo/avatar' , 
    	'filename' =>['./img/'.$nfile] ,
    	'Name' => $nfile ,
    	'Content_Type' => 'image/jpeg'] )->as_string;	
    
     
  3. krypt3r

    krypt3r Elder - Старейшина

    Joined:
    27 Apr 2007
    Messages:
    1,507
    Likes Received:
    389
    Reputations:
    101
    пример есть в perldoc HTTP::Request::Common