|
|
ru.perl
- RU.PERL ----------------------------------------------------------------------
From : Paul Kulchenko 2:5020/400 17 Aug 2000 19:00:46
To : All
Subject : Re: как создать запрос $req->content_type('multipart/form-data'); ??
--------------------------------------------------------------------------------
$req->content_type('multipart/form-data'); ??? Hi, dimka! dimka kuvshinov wrote: > my $req = new HTTP::Request POST => 'http://www.perl.com/cgi-bin/BugGlimpse'; > $req->content_type('application/x-www-form-urlencoded'); > $req->content('match=www&errors=0'); > согласно rfc1867 (http://www.olviko.ru/cgi-bin/showrfc.cgi?rfcno=1867): > > "3.2 Action on submit > > When the user completes the form, and selects the SUBMIT element, the > browser should send the form data and the content of the selected > files. The encoding type application/x-www-form-urlencoded is > inefficient for sending large quantities of binary data or text > containing non-ASCII characters. Thus, a new media type, > multipart/form-data, is proposed as a way of efficiently sending the > values associated with a filled-out form from client to server." > > perldoc LWP UserAgent, и пр перерыл, не знаю, одного, как правильно > сформировать POST запрос. > > Hужно сделать нечто вроде этого, но оно, точно не работает, как формируются > запросы?): > #!/usr/bin/perl -wT > ... обявили все нужные бибилиотеки и все прочее, что требуется. > $file="/usr/local/www/data/file.gif"; > my $req = new HTTP::Request POST => 'http://www.perl.com/cgi-bin/BugGlimpse'; > $req->content_type('multipart/form-data'); > $req->content('$file'); С дальнейшими вопросами быстренько в ru.cgi.perl. там и полный LWP FAQ должен быть. LWP FAQ, может поможет: 1.10. How to upload file? use HTTP::Request::Common; use LWP::UserAgent; use CGI qw(header -no_debug); my $URL = 'http://localhost/cgi-bin/survey.cgi'; my $req = POST $URL, Content_Type => 'form-data', Content => [ name => 'Paul Kulchenko', email => 'paulclinger@yahoo.com', surveyfile => ['./survey.dat'], # this file will be uploaded ]; my $res = LWP::UserAgent->new->request($req); print header, $res->is_success ? $res->content : $res->status_line; > Спасибо за ответ, с меня пиво, если в москве. А если в Kansas City? Best wishes, Paul. --- ifmail v.2.15dev5 * Origin: Trans World Airlines (TWA) (2:5020/400) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.perl/35550057fa88.html, оценка из 5, голосов 10
|