I think the CGI.pm uploadinfo() is what I am looking for.

To answer Gunnar's question: I want to make sure I know the file type I am
dealing with so that I don't try to use print to write  binary data to an
open file handle. When I wrote my first program 4 years ago, I thought I
could use print to write all types of data as with text files, but it never
worked correctly.

Mimi



On 20/06/2008, Beginner <[EMAIL PROTECTED]> wrote:
>
> On 20 Jun 2008 at 11:43, Mimi Cafe wrote:
> > I need to write a cgi program to enable our users to upload files using
> the
> > web browser, but I am not sure how to figure out the type of file the
> user
> > wants to upload (e.g text or binary file). Can CGI.pm accomplish this
> > automatically?
> >
> > Any suggestions welcome.
>
>
> Have a look at this from the highly secretive CGI documentation :-)
>
> When a file is uploaded the browser usually sends along some
> information along with it in the format of headers. The information
> usually includes the MIME content type. Future browsers may send
> other information as well (such as modification date and size). To
> retrieve this information, call uploadInfo(). It returns a reference
> to an associative array containing all the document headers.
>
>       $filename = param('uploaded_file');
>       $type = uploadInfo($filename)->{'Content-Type'};
>       unless ($type eq 'text/html') {
>          die "HTML FILES ONLY!";
>       }
>
>
> Dp.
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

Reply via email to