<?xml version="1.0" encoding="windows-1252"?>
<node id="958464" title="@CGI $q-&gt;upload() doesnt work properly" created="2012-03-08 07:43:23" updated="2012-03-08 07:43:23">
<type id="115">
perlquestion</type>
<author id="893562">
perlig</author>
<data>
<field name="doctext">
Dear Monks,

i´m desperated ;-) i´m want to use the cgi.pm to upload a file via a webinterface, but the filehandle &lt;$upload_Handle&gt; give exactly nothing back.. :-(

&lt;code&gt;

			if ($main::var{upload_file} ne "") {
				my @new_IP_data;
				if ($main::var{submit} eq "read") {
					my $loaded_IP_list;
					my $allowed_Types = "txt";
					my $max_Size = 4096;
					my $filename = $q-&gt;param('upload_file');
						$filename =~ s/.*[\/\\](.*)/$1/;
						$filename =~ s/\s/_/;
					my $upload = $q-&gt;param('upload_file');
					
					my $file_Size = -s $upload;
						#$file_Size /= 1000;
					if ($file_Size &gt; $max_Size) {
						print "&lt;p&gt;file is too big - only $max_Size allowed - your file got $file_Size bytes&lt;/p&gt;\n";
						(my $kbsize,my $byt) = split(/\./, $file_Size);
						print "~ $kbsize KB";
						
						exit;
					}
					(my $file_ID,my $type) = split(/\./, $filename);
					if($filename !~ /^\w+\.($allowed_Types)/) {
						print "only *.txt allowed";
						
						exit;
					}
					$file_ID = time();
					if (-e "$upload_Dir/$file_ID.$type") {
						print "Content-type: text/html\n\n";
						print "file already exist";
					} else {
	#### doesnt work
	$main::q::DISABLE_UPLOADS = 0;
	my $upload_Handle = $q-&gt;upload($filename);
	chdir($upload_Dir) or die "could not read target folder: $!";
	if (!$upload_Handle &amp;&amp; $q-&gt;cgi_error) {
		print $q-&gt;header(-status=&gt;$q-&gt;cgi_error);
		exit 0;
	}
	my $error = $q-&gt;cgi_error;
    if ($error) {
        print $q-&gt;header(-status=&gt;$error),
              $q-&gt;start_html('Problem'),
              $q-&gt;strong($error);
        exit 0;
    }
	while (&lt;$upload_Handle&gt;) {
        print;
    }
					
	print Dumper $q;
	print $upload;
	
	while(&lt;$upload_Handle&gt;){print $_;}
	print $upload_Dir;
	exit;
&lt;/code&gt;

i still get no output. $q is initialised. dont know how to fix it. 

fyi: on an windows apache it works fine. but now i ported the script to a opensuse box. if i try to upload a file from my windows machine to the linux webserver where the script runs it give nothing back, even no errors.


&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-893562"&gt;
$perlig =~ s/pec/cep/g if 'errors expected';

&lt;/div&gt;&lt;/div&gt;</field>
</data>
</node>
