in reply to How do I enter and retrieve a GIF File from mysql via CGI?
To get a file from a browser, you'll need to use a file upload field. Take a look at the advise other Monks have given on this topic here; using CGI.pm is both the easiest and most foolproof way to go. CGI.pm will put the contents of the file into a scalar for you; to get it into the database, construct an INSERT with placeholders and pass the do function your file variable.
When you want to return the file to the user, you first need to retrieve it from the database with an appropriate fetch command. Once you have it in a scalar, you should print the appropriate header for your filetype (here, "image/gif") and then print your variable. CGI.pm can once again help you out here; this statement will do what you need:
print header(-type='image/gif'), $data;
|
|---|