> I have the following code, which can port 1 image to browser, > when I use Sambar Server for Win32 System. > > > #!C:\perl\bin\perl.exe > > print "Content-type: image/jpeg\r\n\r\n"; > $| = 1; > open (FILE, 'C:/my/param/image.jpg'); > binmode (FILE) ; binmode(STDOUT); > while (<FILE>) { print $_ } close (FILE); > > ########################################### > > And now, I have the following questions : > 1) This script doesn't work in Apache Server at all, should I > code them in another way ? > > 2) This script can only print out 1 image only, what should I > do to print multiple images? Such like Web Counters.
You could use ImageMagick to combine them into one, you could have several <img src="/cgi-bin/your/script?abcdef"> in a row in the HTML or you can use SSI and only generate those several <img> tags by the script. I do not think I'm making much sense here. 1) I guess you know what I mean. Sorry don't have any code by hand. 2) The HTML of the page contains several <IMG> tags, each of them will trigger calling your script. Not sure what good will that be for you though. 3) In the HTML of the otherwise static page you'll have a SSI instruction (sorry, haven't used this for years, can't give you exact syntax) that will call your script. The script will NOT output any image, it'll only output some HTML code containing several <IMG> tags pointing to the individual ciphers. > 3) I've saw some other sample code, they would use to write > as : read (FH, $x, 4096) ; print $x ; > What's the different with the one I wrote ? It's slightly more efficient. You are forcing Perl to search for end-of-line characters in the data. And since it's a binary file your chunks (the data assigned to $_ at a time) will be sometimes small, sometimes big ... It's more efficient to read a file in chunks with size like 4KB or 8KB. > 4) I dont understand why sometime is \r\n, sometime is \r\n\r\n > while sometime is \r\r\n\n. Any difference ? And what are they > actually given impact on the output / read result ? It should never be \r\r\n\n. That's nonsense. There are basicaly three different ways of specifying end-of-line. By the LF character (usualy \n) : Unix By the CR character (\r) : Macintosh By CRLF pair (\r\n) : Windows/DOS/Internet protocols If you do not use binmode() and specify \n in your strings Perl prints the file with whatever end of lines are usual under your operating system, and when reading converts whatever end-of-line are usual under your OS to \n. If you do use binmode you have to take care of the proper end-of- lines yourself. And HTTP protocol specifies that you should use CRLF (\r\n) as end-of- line and that you should put one empty line between the headers and the data. Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]