Re: Determine upload file type

[email protected] (Gunnar Hjalmarsson)
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
Mimi Cafe wrote:
> I need to write a cgi program to enable our users to upload files using the
> web browser,

Okay. As Owen mentioned, the module CGI::UploadEasy may be helpful.

> 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?

If you need that information before a file is uploaded, the answer is 
no. CGI.pm (and, consequently, CGI::UploadEasy) does provide MIME type 
based on the file extension and browser settings _after_ the files have 
been uploaded, but note that that info is not a reliable way to 
determine e.g. text or binary.

What's the purpose of your desire to know the file type?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.