#!/usr/bin/perl -T sub response { (my $status, my $msg)=@_; print "Content-Type: text/html\n"; #print "Status: $status\n"; print "\n"; print $msg; print "\n"; exit 0; } if ($ENV{'REQUEST_METHOD'} ne "POST") { &response(201, "Request method is not POST"); } my $f=$ENV{'QUERY_STRING'}; $f=~/([-a-zA-Z0-9:;_.\/]+)/; my $arg=$1; (my $action, my $offset, my $filen)=split(/;/, $arg); if ($filen=~/\.\./) { &response(500, ".. not allowed in path"); } $DIR="YOUR_UPLOAD_DIR"; if ($filen eq "") { &response(201, "No filen given"); } $path=$filen; $path=~s/([^\/]+)$//; mkdir($DIR . $path); if ($action eq "C") { open(OUT, ">" . $DIR . $filen) || &response(201, "Cannot open output file $DIR$filen"); } else { open(OUT, "+<" . $DIR . $filen) || &response(201, "Cannot open output file $DIR$filen"); seek(OUT, $offset, 0); } while () { print OUT $_; } close(OUT); &response(200, "OK");