I'm getting this error: Undefined subroutine &main::error called at E:\Inetpub\scripts\bis\mkrdb\upload_files.pl line 83 in this portion of the script:
# This will create the new file in the new location until ( sysopen OUTFILE, UPLOAD_DIR . $uploadedfile, O_RDWR|O_CREAT|O_ +EXCL, 0777 ) { $uploadedfile =~ s/(\d*)(\.\w+)$/($1||0) + 1 . $2/e; $1 >= MAX_OPEN_TRIES and error( $grab_file, "Unable to save your f +ile. File 1" ); }
I had this script running on a developement box under apache and it worked just fine. Now i moved it to a production server and using IIS 5.0 and its not working. Here is the entire upload portion of the script:
UPLOAD_FILE: { for my $file_num (1..5) { my $file = $grab_file->param("file$file_num") or next UPLOAD_F +ILE; my ($base,$path,$type)=@_; my $file_handle = $grab_file->upload("file$file_num"); my $buffer = ""; if (!$file && $grab_file->cgi_error) { print $grab_file->header(-status=>$grab_file->cgi_error); exit 0; } if ($file) { $file =~ s/</&lt;/g; $file =~ s/>/&gt;/g; fileparse_set_fstype("MSWin32"); ($base,$path,$type) = fileparse($file,'\..*'); my $type = lc $type; my $uploadedfile = $base . $type; $uploadedfile =~ s/[^\w.-]/_/g; if ( $uploadedfile =~ /^(\w[\w.-]*)/ ) { $uploadedfile = $1; } else { error( $grab_file, "Invalid file name; files must star +t with a letter or number." ); } # This will create the new file in the new location until ( sysopen OUTFILE, UPLOAD_DIR . $uploadedfile, O_RDW +R|O_CREAT|O_EXCL, 0777 ) { $uploadedfile =~ s/(\d*)(\.\w+)$/($1||0) + 1 . $2/e; $1 >= MAX_OPEN_TRIES and error( $grab_file, "Unable to + save your file. File 1" ); } # The file needs to be set to binmode in order to save it +on a Win32 system binmode OUTFILE; binmode $file_handle; # This will write the info into the new file while ( read($file_handle,$buffer,BUFFER_SIZE) ) { print OUTFILE $buffer; } close OUTFILE; my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$file_size,$ati +me,$mtime,$ctime,$blksize,$blocks) = stat($file); # This will store the file and size in the database push @statement,"INSERT INTO documents (record_id, documen +t, size) VALUES ('$record_id', '$uploadedfile', '$file_size')"; } } }
Thanks in advance for your help. -Kiko

In reply to I'm getting an error using error() by Kiko

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.