| Subject: | Re: Determine upload file type |
|---|---|
| From: | dermot@xxxxxxxxxxxxxxxx (Beginner) |
| Date: | Fri, 20 Jun 2008 12:09:37 +0100 |
| Newsgroups: | perl.beginners.cgi |
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.
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Determine upload file type, Owen |
|---|---|
| Next by Date: | Re: Determine upload file type, Gunnar Hjalmarsson |
| Previous by Thread: | Re: Determine upload file type, Owen |
| Next by Thread: | Re: Determine upload file type, Gunnar Hjalmarsson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |