Hi,
Thanks, thats what I was thinking... he is what I have atm:
my $uploaddir = $CFG->{build_static_path} . '/ajax_upload/tmp_uplo
+ads';
use Links::Plugins;
my $PCFG = Links::Plugins::get_plugin_user_cfg ('ImageUpload');
my $maxFileSize = $PCFG->{max_file_size} * 1024 * 1024; # 1/2mb
+max file size...
my $num_max_files = $PCFG->{MaxNumberImages};
my $image_field = $PCFG->{ImageField};
use CGI;
my $cgi = new CGI;
my $queueID = $cgi->param('queueID');
use Data::Dumper;
print $IN->header;
# Where the data gets passed too...
my $handle = $cgi->param('Filedata');
my $temp_id = $cgi->param('temp_id');
my $filename = $cgi->param('Filename');
my $file = $cgi->param('Filedata');
my $count = $DB->table("AJAXFileUploads")->count( { temp_id => $te
+mp_id } ) || 0;
# print "TempID : $temp_id ";
if ($DB->table("AJAXFileUploads")->count( { temp_id => $temp_id, u
+pload_filename => $filename } ) > 0) {
print $IN->header;
print qq|This file already seems to have been uploaded...|;
exit;
}
print STDERR qq|$count > $num_max_files \n|;
if ($count >= $num_max_files) {
print $IN->header;
print qq|Sorry, you can only upload $num_max_files ...|;
exit;
}
print STDERR "Filename: $filename \n";
print STDERR "Temp ID: $temp_id \n";
print STDERR "Filename 1: $filename \n";
my $test = $filename =~ tr{&[]ÀÂÄàâäÇçÉÊÈËéêèëÏÌÎïìîÖÔÒöôòÜÛÙüûù?!
+;«»()" íóñÑáéóúÁÉÍÓÚ}{___aaaaaacceeeeeeeeiiiiiioooooouuuuuu_________i
+onnaeouaeiou};
print STDERR "FOO REPLACE: $test \n";
print STDERR "Filename 2: $filename \n";
my $count = $DB->table("AJAXFileUploads")->count( { temp_id => $te
+mp_id } ) || 0;
if ($DB->table("AJAXFileUploads")->count( { temp_id => $temp_id, u
+pload_filename => $filename } ) > 0) {
print $IN->header;
print qq|This file already seems to have been uploaded...|;
exit;
}
print STDERR qq|$count > $num_max_files \n|;
if ($count >= $num_max_files) {
print $IN->header;
print qq|Sorry, you can only upload $num_max_files ...|;
exit;
}
my @tmp = split /\./, $filename;
if ($tmp[$#tmp] !~ /docx?|ppt|pps|pptx|ppsx|pdf/i) {
print qq|Invalid file type...|;
print STDERR "file has been NOT been uploaded... \n";
exit;
}
print STDERR "Making dir: $uploaddir/$temp_id \n";
mkdir("$uploaddir/$temp_id");
open(WRITEIT, ">$uploaddir/$temp_id/$filename") or die "Cant write
+ to $uploaddir/$filename. Reason: $!";
while (<$handle>) {
print WRITEIT $_;
}
close(WRITEIT);
my $check_size = -s "$uploaddir/$temp_id/$filename";
print STDERR qq|Main filesize: $check_size Max Filesize: $maxFile
+Size \n\n|;
if ($check_size < 1) {
print $IN->header();
print STDERR "ooops, its empty - gonna get rid of it!\n";
print qq|File is empty...|;
print STDERR "file has been NOT been uploaded... \n";
} elsif ($check_size > $maxFileSize) {
print $IN->header();
print STDERR "ooops, its too large - gonna get rid of it!\n";
print qq|File is too large...|;
print STDERR "file has been NOT been uploaded... \n";
} else {
print $IN->header();
print "1";
print STDERR "file has been successfully uploaded... thank you
+.\n";
$DB->table("AJAXFileUploads")->add( {
temp_id => $temp_id,
upload_filename => $filename,
timestamp => time(),
rand_id => $queueID
} ) || die $GT::SQL::error;
}
Not too sure what you mean by upgrading/degrading?
TIA!
Andy |