Someone please help. Thanks, Kiko.#!/perl/bin/perl use strict; use CGI; use File::Basename; use Fcntl qw( :DEFAULT :flock); use CGI::Carp qw(fatalsToBrowser); use constant UPLOAD_DIR => "files_uploaded/"; use constant BUFFER_SIZE => 16_384; # Amount of upload file to + read at one time use constant MAX_OPEN_TRIES => 100; $CGI::DISABLE_UPLOADS = 0; $CGI::POST_MAX = -1; my $grab_files = CGI->new; my $donepage = "upload_complete.pl"; UPLOAD_FILE: { for my $file_num (1..5) { my $file = $grab_files->param("file$file_num") or next UPLOAD_ +FILE; my $filename = $grab_files->param("file$file_num"); my ($base,$path,$type)=@_; my $file_handle = $grab_files->upload("file$file_num"); my $format = $grab_files->uploadInfo($file)->{'Content-Type'}; my $buffer = ""; if ($file) { $filename =~ s/</</g; $filename =~ s/>/>/g; fileparse_set_fstype("MSWin32"); ($base,$path,$type) = fileparse($filename,'\..*'); my $type = lc $type; my $uploadedfile = $base . $type; $uploadedfile =~ s/[^\w.-]/_/g; if ( $uploadedfile =~ /^(\w[\w.-]*)/ ) { $uploadedfile = $1; } else { error( $grab_files, "Invalid file name; files must star +t with a letter or number." ); } # This will create the new file until ( sysopen OUTFILE, UPLOAD_DIR . $uploadedfile, O_RDWR +|O_CREAT|O_EXCL ) { $uploadedfile =~ s/(\d*)(\.\w+)$/($1||0) + 1 . $2/e; $1 >= MAX_OPEN_TRIES and error( $grab_files, "Unable to + save your file. File 1" ); } while ( read($file_handle,$buffer,BUFFER_SIZE) ) { print OUTFILE $buffer; } close OUTFILE; } } } # Send them to the confirmation page. print $grab_files->redirect($donepage);
In reply to Files are corrupted after uploading by Kiko
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |