来自远程源的perl输出图像

时间:2014-03-20 04:49:47

标签: perl

所以我试图使用脚本简单地通过它代理一些图像。图像托管在远程服务器上,因此我需要下载图像并显示它。这是我到目前为止的代码:

    binmode STDOUT;
    print "Content-type: image/jpeg\n";

    #DB commands to find the image

    my $file = $image_folder."/".$file_real."0000.jpg";
    print $file;
    my $html0 = get($file);

    print $html0;

由于某些原因,这不起作用,当我将标题更改为html并打印html0时,它会显示数据,但是当我将标题更改为jpeg或png时,它无法编译!

1 个答案:

答案 0 :(得分:2)

header中需要两个返回字符:

print "Content-type: image/jpeg\n\n";

此外,还应确保文件也加载到binmode