Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

CGI open of tmpfile

by darshan_atha (Acolyte)
on Oct 22, 2002 at 11:42 UTC ( [id://207037]=perlquestion: print w/replies, xml ) Need Help??

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

i have written code for uploading an image when i try to upload an image i found error like CGI open of tmpfile: No such file or directory i found on site while surfing reason for window operating system "It means that CGI.pm could not find a temp directory to write to. When you upload large files, it temporarily stores them in the temp directory. If you are on a Windows system, just make sure that your C:\Temp directory is present, and that the IUSR_XXX account has write access to it". i am using linux server, does anybody has answere to it thanx

Replies are listed 'Best First'.
Re: CGI open of tmpfile
by robartes (Priest) on Oct 22, 2002 at 12:27 UTC
    CGI.pm will look among the following directories for one that is writeable to your CGI user (non-Unix directories left out):
    Contents of environment variable TMPDIR /usr/tmp /var/tmp /tmp /temp current working directory
    In your case, none of the above directories seem to be writable to your CGI user.

    The easiest solution is probably to set $ENV{'TMPDIR'} in your code to point to a directory that is writable to your CGI user.

    CU
    Robartes-

Re: CGI open of tmpfile
by tune (Curate) on Oct 22, 2002 at 12:30 UTC
    If you have your temp dir on an unordinary place, just do this:
    BEGIN { $TempFile::TMPDIRECTORY = '/mytmp' } use CGI;
    Or edit your CGI.pm in the right place:
    # HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES. # UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING. # $TempFile::TMPDIRECTORY = '/usr/tmp';

    --
    tune

      I don't think that this is particularly good advice. Please correct me if I am wrong, but the CGI docs clearly state that temp dirs are found in the following order:
      • ~user/tmp
      • $ENV{TMPDIR}
      • the usual suspects (/usr/tmp, /var/tmp, C:\temp, /tmp, /temp, ::Temporary Items, and \WWW_ROOT)
      I don't see any mention of it looking at the value of $TempFile::TMPDIRECTORY (whatever that might be) and I certainly wouldn't recommend anyone start hacking CGI.pm.

      rdfield

        You are right. But what if he or his sysadmin created another tmp directory, and disabled all the places, where CGI.pm looks after? I don't think that's impossible. What can he do then instead of hacking?

        --
        tune

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://207037]
Approved by fglock
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-19 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found