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

Hai all,
When I tried to upload a file using Perl CGI and HTML form, the upload function is returning an undefined filehandle. tmpFileName() function is returning me a temporary file name created in /usr/tmp. I also checked the size of the temp file which is same as the original file. I tried to rename/copy the temporary file. But it is giving me an error such as "Insecure dependency in rename". I am using -T (taint mode)in my script. I don't know why upload function is not returning file handle to my variable. I really appreciate a little help. I also checked a conversation reagarding this issue in perl monks. It is not helping. How can we change the destination of the temporary file creation in CGI.pm?


Hey!I found the solution. I have to give form name of the file as the parameter to the upload function.
my $fh = $q->upload( "file" );
previously it was,
my $file = $q->param( "file" ) || error( $q, "No file received." );
my $fh = $q->upload( $file );
Thanks,

Replies are listed 'Best First'.
Re: Perl CGI-trouble in file uploading
by marinersk (Priest) on Sep 20, 2013 at 23:32 UTC
    How can we change the destination of the temporary file creation in CGI.pm?

    Regarding this one detail, I suspect this is related to what you're looking for -- may not be needed if you've resolved the issue but info is still info:

    #!/usr/bin/perl # Needed to avoid dependence on C:\TEMP being world read+write BEGIN { $TempFile::TMPDIRECTORY = './'; } use strict; use CGI;
Re: Perl CGI-trouble in file uploading
by Anonymous Monk on Sep 20, 2013 at 22:51 UTC