#!/usr/bin/perl # # get xml file details from flash and write to target file # use FunctionLib; use File::Copy; print "Content-type: text/plain\n\n"; #print "Content-type: application/x-www-form-urlencoded\n\n"; $lngTotalBytes = $ENV{'CONTENT_LENGTH'}; # Request.TotalBytes read(STDIN,$skinData,$lngTotalBytes); # Request.BinaryRead(lngTotalBytes) # remove urlencoding $skinData=~s/\+/ /g; $skinData=~s/%(..)/pack("c",hex($1))/ge; $rootdir='..'; ($dummy,$thumbName) = split("=",$ENV{'QUERY_STRING'}); # get the filename $keepname=$thumbName; $thumbName=$rootdir . $thumbName; # make filename relative $backupName=$thumbName . '.bak'; # backup file # Write the file data after creating a backup copy copy($thumbName,$backupName) or die "Backup of" . $thumbName . " to " . $backupName . " failed: $!"; open(fhout,">testfile"); open(fhout,">$thumbName") or die "Error opening " . $thumbName . "for writing: $!"; print fhout "$skinData\n" or die "Error writing to " . $thumbName . " : $!"; close(fhout); # display debugging info or confirm message #print 'File:' . $thumbName . ",Len:" . $lngTotalBytes . "\n"; # Filename and length #print 'Data:' . $skinData . "\n"; # XML data print "XML file saved ($keepname)"; 1;