Perl file upload web form issue

I am using a sections of a script that I have used previously to
upload files from a web based form, which has been successful in the
past [just not at Dreamhost]. The file I am attempting to upload is a
.xls file although I have tried plain text files as well and taken out
the binmode option. I can successfully create a file, but always end
up with a 0kb file.

Is this something that Dreamhost disallows? The only thing I can
figure at this time is that perhaps I am not allowed to write to the
/tmp folder and therefore there is no data to be pulled.

I am using the corect enctype and doing POST not a GET, so this is
not the issue:

I even set the folder to 0777 as a possible fix. Also tried setting
$CGI::DISABLE_UPLOADS to 0 in case it was disabled by default.

Applicable portion of the script:

use CGI;

$query = new CGI;
$filename = $query->param(‘thefile’);

unlink $filepath if (-e $filepath);
open THEFILE, “>$filepath” || die “Can’t open file: $!”;
binmode THEFILE;
while ($bytesread=read($filename,$buffer,1024)) { print THEFILE
$buffer; }
close THEFILE;

stupid mistake here to be fixed easily would be fine by me, but at
this point I don’t think it is. I have tried multiple methods of
writing the data to a file, and can’t even output it to the screen.

Please help! I have to get this working asap.

Hmm. I basically copied and pasted your code just now and tried it… it works.

Have you tried setting the permissions on the cgi script, the folder the cgi script is in, and the folder the .xls file is in to 0755? Also, you probably know this, but the path for Perl to access files is /home/your_username/

I’m not sure what else it could be because it works fine for me :confused:

Actually Perl scripts are not limited to web directories. They could even access directories of other users in the same group.

:cool: Perl / MySQL / HTML+CSS