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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.