create new tag
, view all tags

Bug: On Win2k upload can incorreclty fail with zero size file message

In bin/upload you can incorrectly get a file size of zero from the -s or stat methods on the temporary file produced by Apache on a file upload.

Test case

  • On Win2K
  • Try uploading a file - look for message saying attachment is missing or empty

Fix record

Put close $filePath if( $TWiki::OS eq "WINDOWS"); after line with my $createLink ... on it. Some CGI documentation suggets that Window might need to do a file close before exit.

Other things that seem to work:

  • Put sleep 1 before getting the file size - I don't know how complete a fix this is
  • Copy to a temporary file before checking size


TWiki version: 01 Sep 2001
TWiki plugins: N/A
Server OS: Win2k
Web server: Apache 1.3.14 (Win32)
Perl version: v5.6.0, active state 623
Client OS: Win2k
Web Browser: IE5.5

-- JohnTalintyre - 27 Sep 2001

I've also had problems uploading a zero size file from custom scripts using the Wiki library. This usually happened when I zeroed out a file attached to a page and marked it as "being worked on" by a background process. There was no problem attaching the completed file, but attaching the zero length temporary file failed. My work-around was to lie about the length of the temporary file, setting the value to 1.

-- SimonClift - 18 Dec 2001

Closing a file before exit is good practice for ModPerl, where otherwise you can get file handle leaks that eventually require a web server restart. See ModPerl and http://perl.apache.org/ for more information, latter has a FAQ on porting CGI code to mod_perl that mentions this issue. We should really put in cleanup handlers for use with mod_perl so that files are always closed even if the script is aborted or the user hits the Stop button on the browser.

I've also had problems under Windows with a Perl process that kept a file open, causing CygWin to show the file ownership as null (i.e. blank string in ls -l) and to prevent file being removed.

-- RichardDonkin - 04 Mar 2002

Category: TWikiPatches
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2005-02-15 - SamHasler
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.