a_login has asked for the wisdom of the Perl Monks concerning the following question:

when using a web form to upload a file i need to know the location of the local file created by the web server. using the param() thing i can get the name of the uploaded file(on the clients machine) and a file pointer. i can use the upload() option to get a file handle. so is there any way to get the name of the file on the server either from the CGI module or from the file handles it provides?

tanks.
gimpboy
  • Comment on location of file on server for file uploaded in a web form

Replies are listed 'Best First'.
Re: location of file on server for file uploaded in a web form
by japh (Friar) on Dec 20, 2001 at 11:50 UTC
    pasted from CGI.pm - a Perl5 CGI Library - The HTML Shortcuts Section

    When processing an uploaded file, CGI.pm creates a temporary file on your hard disk and passes you a file handle to that file. After you are finished with the file handle, CGI.pm unlinks (deletes) the temporary file. If you need to you can access the temporary file directly. Its name is stored inside the CGI object's "private" data, and you can access it by passing the file name to the tmpFileName() method:

    $filename = $query->param('uploaded_file'); $tmpfilename = $query->tmpFileName($filename);