#!/app/gmd/bin/perl use strict; use CGI; my $upload_dir = "/tmp"; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year += 1900; $mon++; my $timestamp = sprintf("%4d-%2.2d-%2.2d-%2.2d:%2.2d:%2.2d",$year,$mon,$mday,$hour,$min,$sec); my $query = new CGI; if ( $query->param("import_file") eq "" ) { exit }; my $filename = $query->param("import_file"); $filename =~ s/.*[\/\\](.*)/$1/; $filename = $timestamp."-".$filename; my $upload_filehandle = $query->upload("import_file"); open UPLOADFILE, ">$upload_dir/$filename"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE; #my $goodies; #open UPLOADFILE, "$upload_dir/$filename"; #while ( ) { # $goodies .= $_; #} #close UPLOADFILE; print $query->header ( ); opendir DIR , $upload_dir or die "Flaming death! No Upload folder! : $!\n"; my @removedfiles; my $fullpath; foreach my $file ( readdir(DIR) ) { $fullpath = "$upload_dir/$file"; if ( -f $fullpath ) { my $time = (stat($fullpath))[9]; #print "$fullpath ".localtime(time)." - ".localtime($time)." > 6
"; if ( time - $time > ( 60*60*24*180 ) ) { # s->min->h->day * 180 unlink $fullpath; push ( @removedfiles, $file ); } } } my $delfiles = join ( "
", @removedfiles); print < File Uploaded Successfully

Thanks for uploading your file, it's saved to '$filename'!

Your file:$filename

Go to the upload directory:Uploads

Files Removed from upload folder for being older than 180 days :

$delfiles END_HTML