Perl open local / server image

Time:2021-4-21

Reprinted in my blog Garden
https://www.cnblogs.com/kenso…

index.html

<html>
<body>
<h2> perl read img </h2>

<img src = "display.html">

</body>
</html>

display.html It can be rewritten as display.cgi

display.html

#! /usr/bin/perl

#Define picture and picture type (can be changed into variable according to requirement)
$image = "1.jpg";
$imgType = 'jpg';

#Open picture
open(IMG, "$image") or die;

#Open with binary
binmode IMG;
binmode STDOUT;

#Output
print "Content-type: image/$imgType\n\n";
print while (<IMG>);

close(IMG);

exit(0);

Recommended Today

Review of SQL Sever basic command

catalogue preface Installation of virtual machine Commands and operations Basic command syntax Case sensitive SQL keyword and function name Column and Index Names alias Too long to see? Space Database connection Connection of SSMS Connection of command line Database operation establish delete constraint integrity constraint Common constraints NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY DEFAULT […]