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

When Perl uploads a file through the browser to a specified directory, does it simply go straight to that directory or does Perl upload it somewhere else first and then copy it to the specified directory after the file is finished uploading? Thanks for your insight Perl Monks!

Replies are listed 'Best First'.
Re: file upload question
by matija (Priest) on May 05, 2004 at 16:48 UTC
    It doesn't "upload to a specified directory". It uploads to a temporary directory, and CGI then passes you a file handle. You can use that filehandle to copy the file to the "specified directory".
      Thanks for your reply matija! Here's more background on the situation.. I have a little uploader script that I wrote to upload files to my server. It works fine until I try larger files and I'm assuming the script is timing out after 5 or so minutes. My host told me that the reason it's "crashing" on larger uploads is because I'm uploading to a "temp" directory and the servers see this as a dead link after a period of time. They said that if I were uploading to another designated directory, then this wouldn't happen. Any thoughts?

        Check out the docs for CGI (perldoc CGI), search specifically for the string upload. This should give you some information as to how the CGI module works for file uploads.

        --MidLifeXis

Re: file upload question
by cfreak (Chaplain) on May 05, 2004 at 18:27 UTC

    If you use CGI then yes it stores it in a temporary location. Also be aware that in CGI file uploads are limited (10 megs by default I think, check the docs) and this will also return a 500 code (internal server error).

    HTH
      Thanks for that default level.. I've read that I can add this $CGI::POST_MAX=n; to adjust the default size constraints. :)