[英]Images uploaded with Via Perl Net::FTP get corrupted
Why am I always getting corrupted image file when uploading to FTP server? 为什么上传到FTP服务器时总是出现损坏的图像文件? .gif
image doesn't get corrupted, only .jpeg
/ jpg
and .png
get corrupted. .gif
图像不会损坏,只有.jpeg
/ jpg
和.png
会损坏。
sub png{
my $ftp=Net::FTP->new($fhost)or die &ftpErr;
$ftp->login($hostname, $hostpass);
my $img=$ftp->put("$file");
$ftp->get($img);
$ftp->quit;
our $image="$img";
our $shot=$window->Photo(-format=>'png',-file=>"$image");
$window->Label(-relief=>'ridge',-image=>$shot,-width=>50,-height=>50)->pack(-anchor=>'n');
}
sub jpeg{
my $ftp=Net::FTP->new($fhost)or die &ftpErr;
$ftp->login($hostname, $hostpass);
my $img=$ftp->put("$file");
$ftp->get($img);
$ftp->quit;
our $image="$img";
our $shot=$window->Photo(-format=>'jpeg',-file=>"$image");
$window->Label(-relief=>'ridge',-image=>$shot,-width=>50,-height=>50)->pack(-anchor=>'n');
}
You are transferring the files in the default mode, which is ASCII. 您正在以默认模式ASCII传输文件。 This mode translates line ends. 此模式转换行尾。 To transfer binary files use binary mode: 要传输二进制文件,请使用二进制模式:
$ftp->binary;
$ftp->put(...);
$ftp->get(...);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.