in reply to Re: Uploading Files
in thread Uploading Files

Hi, This is the part of my script that is supposed to upload upto 5 files. Everything else in my script works put the portion. I'm passing file1,file2,...file5 to this script. When i pass it file1 i get this error "Can't use an undefined value as a HASH reference at c:\phpdev3\scripts\mkrdb\SAVE_N~1.PL line 81" which happens to be the line where $format is. But when i pass it file2 or 3 or 4 or 5 i don't get the error and my script works but the file upload portion below.
UPLOAD_FILE: { for my $file_num (1..5) { my $file = $grab_file->param("file$file_num") or next UPLOAD_F +ILE; if ($file) { my $buffer; my $file_handle = $grab_file->upload($file); my $format = $grab_file->uploadInfo($file)->{'Content-Type'} +; # This will create the new file sysopen OUTFILE, UPLOAD_DIR . $file, O_CREAT or die "Can't + open UPLOAD_DIR$file: $!"; while ( read( $file_handle, $buffer, BUFFER_SIZE ) ) { print OUTFILE $buffer; } close (OUTFILE); # This will store the file name in the database push @statement,"INSERT INTO documents (record_id, document) + VALUES ('$record_id', '$file')"; } } }
Thanks for your help, Kiko