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

I use CGI.pm to deal with upload.But the script was broken and gave me an error message "CGI open of tmpfile: No such file or directory".
I'm sure I had make a directory to save the uploaded file and make it can be writed by everyone.
I don't know what is "tmpfile".Can you help me?
Thanks!

Replies are listed 'Best First'.
Re: upload error
by lhoward (Vicar) on Aug 23, 2000 at 19:13 UTC
    The CGI module uses a temporary file for the file upload. Sounds like your problem is with permissions (or something similar) dealing with the temporary files it needs to create. See the -private_tempfile section of the CGI module docs for more details on how to set the temp file directory.
RE: upload error
by ColtsFoot (Chaplain) on Aug 23, 2000 at 19:06 UTC
    Perhaps an example of your code may help someone to
    solve your problem
      a section of my code:
      #OS is Win2000 server $picdir="d:\\inetpub\\wwwroot\\m_html\\news_pics\\"; use CGI; $delfer=new CGI; $file=$delfer->param('file'); $file=~/[\/|\\]?(\w+\.\w+)$/; $filename=$1; &print_error("jpg or gif please") if(($filename!~/\w+\.jpg/)&&($filena +me!~/\w+\.gif/)); &print_error("filename less than 20") if(length($filename)>20); &print_error("has been in existence") if(-e ("$picdir$filename")); open(IMAGE,">$picdir$filename") || &print_error("fail to open file"); binmode IMAGE; binmode $file; while($bytes=read($file,$buffer,1024) ) { $sum+=$bytes; if ($sum> 102400) { close IMAGE; unlink($picdir.$filename); &print_error("less than 100k"); } print IMAGE $buffer; } close IMAGE; unless($sum) { unlink($picdir.$filename); &print_error("can not be zero"); } sub print_error{......}