CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Handling mutiple content types

 



zak100
Novice

Nov 15, 2013, 9:28 AM

Post #1 of 2 (354 views)
Handling mutiple content types Can't Post

Hi,
I am trying to display both image and text data. I have put them in different scripts but image is not displayed. The first script has text content and incorporates another script which displays only the imageFirst script:


Code
#!C:/Perl64/bin/perl.exe 

print print "Content-type: multipart/x-mixed-replace;boundary=UPDATED\n\n";
print <<HTML;
<html>
<head>
<title> A Simple Perl CGI </title>
</head>
<body>
print "--UPDATED";
<img src="my_img.pl" />
print "--UPDATED";
<h1>A Simple Perl CGI </h1>
</body>
HTML
exit;


The other script is:

Code
select(STDOUT); $| = 1;   #unbuffer STDOUT 
print "Content-type: image/gif\n\n";

open (IMAGE, '<', 'D:/en.gif');
print <IMAGE>;
close IMAGE;
exit;


Can somebody guide me to solve this problem

Zulfi.


Zhris
User

Nov 15, 2013, 6:45 PM

Post #2 of 2 (349 views)
Re: [zak100] Handling mutiple content types [In reply to] Can't Post

Hi,

If you run the image script directly do you just get garbled binary?

After opening the image file and before printing, try setting binmode:


Code
binmode IMAGE;


Also, if you are using html <img> to display the image script, you don't need a multipart content type for your html script, just use text/html if appropriate.

Chris


(This post was edited by Zhris on Nov 15, 2013, 6:47 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives