Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: tr{}{} doesn't wanna work.. what am I doing wrong?

by ultranerds (Pilgrim)
on Feb 24, 2012 at 13:26 UTC ( #955918=note: print w/ replies, xml ) Need Help??


in reply to Re: tr{}{} doesn't wanna work.. what am I doing wrong?
in thread tr{}{} doesn't wanna work.. what am I doing wrong?

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


Comment on Re^2: tr{}{} doesn't wanna work.. what am I doing wrong?
Download Code
Re^3: tr{}{} doesn't wanna work.. what am I doing wrong?
by Corion (Pope) on Feb 24, 2012 at 13:43 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://955918]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2014-07-24 03:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (156 votes), past polls