Hi thanks
talexb I think the problem is not with my script, but rather with my apache server, as I have just discovered. I invoked the cgi from another computer (other than the web server), I could see the images being properly displayed. Just that when I tried to access from the server box, the cgi hangs. So I am going to look a bit more into how my apache server was configured, hopefully that could give me more clue.
I have tried to add the attachement option to my script, and it still not work from the server, but it works from a differnet computer with or without the attachment option.
Thanks for the comment anyway. ;-)