How can I reliably determine uploaded file name in a Perl CGI script? -


File name sent to the Perl CGI (using CGI.pm) script from an uploaded form depends on the client machine and In this, the client-dependent path separator is a trusted way of parsing the parameter passed to determine the filename (usually the last sub string after separator from the last path)

When I'm using the customer MSIE (only the Windows path The Th) I've only experienced a problem with the path separator). I have used quite a regular regular expression to handle it, however, you can increase the expression (or split) regularly, from the most common path separator - '/', '\' and sometimes ':'.

Alternatively, you should be able to use the file system type from the useragent string (perhaps by using), assuming that you call the Fileparse_set_fstype function of File: BaseName before parsing the file. can do.

Something like this:

  Use the file: basinum; Use HTTP: BrowserDetect; # $ Get $ file_file in dollar name and file name in $ user_agent_string My $ browser = HTTP :: BrowserText-> New ($ user_agent_string); My $ ostype; $ Ostype = 'MSWin32' if $ browser- & gt; window; $ Ostype = 'Unix' if $ browser- & gt; Unix; # More tests are available fileparse_set_fstype ($ ostype); My $ filename = basename ($ upload_file);  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -