in reply to Re: Re: Re: Re: file uploading
in thread file uploading
When a browser uploads a file to your server as part of a form, it simply reads the local bytes, munges them all into an HTTP-friendly packet and sends off the whole lot. What CGI.pm does for you is split off those bytes, save them to a temporary file and then give you access to a filehandle - basically a way of reading the bytes back in from the temporary file and doing somewhere else with them - writing back out to a file of your choosing, parsing, dividing-by-the-number-you-first-thought-of...whatever.
In order to have some idea of what the file actually contains - whether it's bunch of bytes that make up a picture, or the aforementioned nice'n'readable text file, you either need to examine the also-supplied-by-CGI.pm MIME type for the file, which will tell you whether it's a gif, an mp3, a text file or whatever. Generally, one does this in order to have an idea of the extension to then give the filename - never trust user-supplied filenames :)
Hope this helps
Ben
|
|---|