Skip to content

Instantly share code, notes, and snippets.

@fujiwara
Created March 3, 2010 07:52
Show Gist options
  • Save fujiwara/320421 to your computer and use it in GitHub Desktop.
Save fujiwara/320421 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw/ fatalsToBrowser /;
use Digest::MD5 qw( md5_hex );
my $q = CGI->new();
my $imagedata = $q->param("imagedata");
my $filename = "image/" . md5_hex(time() . $$ . rand()) . ".png";
open my $fh, ">", $filename or die $!;
print $fh $imagedata;
close $fh;
print "Content-Type: text/plain; charset=utf-8\n";
print "\n";
printf "http://%s/%s\n",
($ENV{HTTP_HOST} || $ENV{SERVER_NAME}),
$filename;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment