Created
May 31, 2009 14:57
-
-
Save shelling/120909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use CGI qw(:all); | |
print header(-charset => "utf-8"); | |
start_html; | |
print h2("image list"); | |
print p( | |
a { | |
href => "image-upload.pl", | |
style => "text-decoration: none;" | |
}, | |
"upload new image", | |
); | |
for (glob("photos/*")) { | |
print a { href => $_ }, $_; | |
print br; | |
} | |
print end_html; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# simple image uploading using cgi | |
use 5.010; | |
use CGI qw(:all :cgi-lib); | |
use Data::Dumper; | |
print header(-charset => "utf-8"), | |
start_html(-title => "image-upload.pl"); | |
print h2("image upload"); | |
print p("test cgi for image uploading"), | |
p ( | |
a { href => "image-list.pl", style => "text-decoration: none;" }, "list image" | |
); | |
print start_multipart_form, | |
filefield(-name => "uploaded_data", -default => "start value"), | |
submit(-name => "upload", -value => "submit"), | |
end_form; | |
$filename = param("uploaded_data"); | |
if ($filename =~ m/(png|gif|jpg)$/) { | |
open IMAGE, " > photos/$filename" or die; | |
while (<$filename>) { | |
print IMAGE $_; | |
} | |
print img { src => "photos/$filename" }; | |
} else { | |
print "uploaded data is not available image format" if $filename; | |
} | |
print end_html(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment