#this is a stripped down version of the code #no colors, no fonts, no extra input buttons #--------------------------------------- #this is part of which outputs the #the form and makes the call to upload_proc.cgi #when the Upload button is clicked #---------------------------------------
Data Upload
  ==>>
#--------------------------------------- #end of partial upload.cgi #--------------------------------------- #--------------------------------------- #this is the stripped down #--------------------------------------- #!/usr/bin/perl use utf8; use encoding "utf-8"; use CGI; use Bos::util qw($dbh); use Text::CSV; use strict; Bos::util::db_connect(); my $user = Bos::util::authenticate("COOKIE","COOKIE"); Bos::util::auth_error($user); if ($user->{'Type'} ne "B") { Bos::util::user_error("
Access denied.
Your account is not authorized for this function.
"); } my $query; my $sth; my $myrow; my $cgi = Bos::util::cgi_query(); if( $cgi->param('submit') eq "Upload" ) { Bos::util::send_header("New Data Results", ""); chdir( "/ccshome/www/customer_data_upload" ) or die; #permissions are 1777 on this folder my $new_file_data = upload_file($cgi->param('file_data')); } Bos::util::send_footer; #--------------------------------------- #this is the that is in upload_proc.cgi #--------------------------------------- sub upload_file { my $filename = shift; return Bos::util::get_file($filename); } #--------------------------------------- #end of upload_proc.cgi #--------------------------------------- #--------------------------------------- #this is the #extracted from the Bos::util.pm #used by upload_proc.cgi #--------------------------------------- sub get_file { my $filename = shift; my $query = cgi_query(); return 0 unless defined $filename; my $fh = $query->upload( $filename ); if( $fh ) { rename("${filename}.csv", "${filename}.old.csv"); # open for writing open(DATA,">${filename}.csv") or die "Can't create ${filename}.csv ($!)\n"; while( <$fh> ) { print DATA; # write the file out } close(DATA); return 1; # successful return # there must be a CGI error } else { my ($errstr) = $query->cgi_error; if ($errstr) { print "CGI error($filename): $errstr
\n"; } else { print "CGI nodata($filename)
\n"; } return 0; } }