You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bart Terryn <ba...@grafikon.com> on 2005/04/30 13:52:02 UTC

RE: File upload problem

Hi everybody

It turned out to be a CGI.pm problem related to the setup I'm running.
And here is the solution:

Apparantly CGI.pm V3.01 no longer allows you to force your TMPDIRECTORY to a
folder of your choice.
This used to be possible by uncommenting line 26 to read something like:
	$CGITempFile::TMPDIRECTORY = 'C:/Temp';

But in the find_tempdir routine this was ignored by line 3753:
  	undef $TMPDIRECTORY;

I filed a request to the CGI.pm buglist to change this to the old behaviour.

Sorry if you feel this was not a mod_perl issue, but I was sidetracked by
the fact that this problem only occurred under the mod_perl environment.

But all is bright and shining again

Bart


-----Original Message-----
From: Bart Terryn [mailto:bart@grafikon.com] 
Sent: Saturday, April 30, 2005 11:42 AM
To: modperl@perl.apache.org
Subject: File upload problem 

Hi,

I'm have been running mod_perl for a while now.
Current situation is:
	-Win 2000 SP2
	-Apache 2.0.47
	-mod_perl 1.999.22
	-Perl 5.8.3

http conf:
	Alias /mod_perl/ "C:/Program Files/Apache Group/Apache2/mod_perl/"
	<Location /mod_perl>
 	SetHandler perl-script
 	PerlResponseHandler  ModPerl::Registry
 	PerlOptions -ParseHeaders
 	Options +ExecCGI
	</Location>

But all of the sudden I'm having problems with the file uploads from a form.
In the error.log file I find:
	CGI open of tmpfile: No such file or directory

Note that those same forms gave no trouble before.
Don't know what switch did create the error.
My guess it is the installation of Perl5.8.3 (from a 5.8.1 version) and its
accompagning CGI v3.01.
Have also tried with the lastest 3.08 CGI module from CPAN

I have reduced the error to the following form and its brother mod_perl
script.

Note also that the script is running OK when placed in the cgi-bin folder
(no mod_perl). I know that is not a guarantee that it should work under
mod_perl, but still it is a nice indication.

Form
========
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Upload Test</title>
</head>

<body>
<h4>Upload:</h4>
<form method="post" action="/mod_perl/upload-test.pl"
enctype="multipart/form-data">
<br />
<input name="file" type="file" size="60" /><br />
	<input type="button" value="Cancel" onclick="window.history.go(-3)"
/>

	<input type="submit" value="Upload File" />
</p>
</form>
</body></html>

Script
==========
#!C:\Perl\bin\perl.exe
use CGI;
my $q = CGI->new();
print $q->header, $q->start_html('result'),$q->h1('the uploaded file');
my $filename = $q->upload('file');
print $q->p("filename: $filename");
print $q->p("content:");
print "<pre>";
while (<$filename>) { print; }
print "</pre>"; 
print $q->end_html;

Kind Regards

Bart Terryn