LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Beginner Date: Fri Jun 20 05:09:37 2008 Subject: Re: Determine upload file type
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.
| Navigate in group perl.beginners.cgi at sever nntp.perl.org | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |