#!c:/perl/bin/perl -w my $DATA_DIR='C:/htdocs/test/bigsize_images'; # Path of data directory my $DEFAULT_UPLOAD_DIR='C:/htdocs/test/images/upload'; # Path of work directory ################################################################################ # DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING # ################################################################################ use strict; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $query = new CGI(); ############################################################################## # Übergabeparameter aus Formular # ############################################################################## my $SID= $query->url_param('SID'); my $action= $query->url_param('action'); my $file_name=$query->url_param('filename'); my $IMAGE_DIR='C:/htdocs/test/images/'.$query->url_param('album'); # Path of image album directory if ($query->param('BT_Exit')) { $action = ''; } if ($action eq 'upload') { print $query->header; print &Upload($query, $DEFAULT_UPLOAD_DIR, $file_name, $IMAGE_DIR); } else { print "Content-type: text/html\n\n"; print '({"success":false,"error":"No upload flag request"})'; } ######################################## # Upload Sub # ######################################## sub Upload { my($query, $upload_dir) = @_; my($file_query,$size, $buff, $time, $bytes_count); $size = $bytes_count = 0; $file_query = $query->param("file"); if (! $file_name) { &Error("Bad filename", 1); } #if (-e "$upload_dir/$file_name") { # &Error("File allready exists", 1); #} open(FILE,">$upload_dir/$file_name") || &Error("File not found!", 1); binmode FILE; $time=time(); while ($bytes_count = read($file_query,$buff,1024)) { print FILE $buff; $size += $bytes_count; } close(FILE); #chmod (0644, "$upload_dir/$file_name"); if ((stat "$upload_dir/$file_name")[7] <= 0) { unlink("$upload_dir/$file_name"); &Error("Could not open file", 1); } else { $time = time -$time; print '({"success":true})'; } } ######################################## # HTML Present subs # ######################################## sub Error { my($errortext, $exit) = @_; #print "Content-type: text/html\n\n"; print '({"success":false,"error":"'.$errortext.'"})'; if($exit) { exit; } }