I am trying to add a file upload to an existing web page.
Every time I upload I get a file that is corrupted.
I made sure to set binmode
on the file handle. I also have my input enctype set to multipart/formdata
in my form.
My code is as follows
$article{upload_file_name} = $cgi->param( 'upFile' );
$article{upload_file} = $cgi->upload( 'upFile' );
if ( $article{upload_file_name} ne "" or $article{upload_file_name} ne null ) {
open( UPLOADS, ">$uploads_dir/$article{upload_file_name}" )
or die "Could not open $uploads_dir/$article{upload_file_name}";
binmode UPLOADS;
while ( <$article{upload_file}> ) {
print UPLOADS;
}
close UPLOADS;
}
I also tried this
$article{upload_file} = $cgi->param( 'upFile' );
if ( $article{upload_file} ne "" or $article{upload_file} ne null ) {
open( UPLOADS, ">$uploads_dir/$article{upload_file}" )
or die "Could not open $uploads_dir/$article{upload_file}";
binmode UPLOADS;
while ( <$article{upload_file}> ) {
print UPLOADS;
}
close UPLOADS;
}