我发现我的上传 perl 在我的 apache 上返回空文件,但是用 CURL 发布它可以正常工作:
@FILES = qw (o1.tmp o2.tmp o3.tmp);
foreach $filename (@FILES) {
$ua=LWP::UserAgent->new;
$proxy = "http://$USERNAME:$PASSWORD\@$PROXY_ADD";
$ua->proxy(['http', 'https'], $proxy);
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
my $url = "http://www.XXXXXXXXX.es/handler.php";
my $picture = $filename;
my %args;
my $field_name = "userfile";
my $buf ;
my $buf_ref = $args{'buf'} || \$buf ;
my $value = read_file( $picture , binmode => ':raw' , scalar_ref => 1 );
my $response = $ua->post( $url,
Content_Type => 'form-data',
Content => [ $field_name => ["$picture"] ]
);
print $response->content;
}
返回空文件:
root@dasdasd:/var/www/upload# ls -l
total 0
-rw-r--r-- 1 www-data www-data 0 oct 30 20:08 tmp_30-10-2013_0808pm_5554.tmp
-rw-r--r-- 1 www-data www-data 0 oct 30 20:08 tmp_30-10-2013_0808pm_8437.tmp
-rw-r--r-- 1 www-data www-data 0 oct 30 20:08 tmp_30-10-2013_0808pm_8629.tmp
但是有了这个 cURL 代码:
XXX-MacBook-Pro:Desktop xxxxxx$ curl -X PUT --header "Content-Type:multipart/form-data" --header "Name: 1" --data-binary "@2.gif" -v http://www.xxxxxxxxxx.es/handler.php
作品:
root@Arvaro:/var/www/upload# ls -l
total 4
-rw-r--r-- 1 www-data www-data 0 oct 30 20:08 tmp_30-10-2013_0808pm_5554.tmp
-rw-r--r-- 1 www-data www-data 0 oct 30 20:08 tmp_30-10-2013_0808pm_8437.tmp
-rw-r--r-- 1 www-data www-data 0 oct 30 20:08 tmp_30-10-2013_0808pm_8629.tmp
-rw-r--r-- 1 www-data www-data 6 oct 30 20:40 tmp_30-10-2013_0840pm_1978.tmp
^^^
not empty
任何人都可以在这里放一些光吗?
谢谢