Sometimes I really hate going home. I’m on Christmas break, and I’ve spent the majority of my time just watching movies in my basement. I got really bored, so yesterday morning while I was watching “Juno” (love that movie), I wrote an Omegle script for irssi. I just made up a google code page for download, so have at it irssi users. Maybe I’ll get around to adding it to the big list of irssi scripts sometime soon.
Posted in
Uncategorized at December 25th, 2009.
No Comments.
Got my mail server up and running (finally). Now you can e-mail me at will@worrbase.com.
Posted in
Uncategorized at December 14th, 2009.
No Comments.
So I started writing a netboot server for floor. I decided to start writing the web interface first, and learn myself some mason, web perl, and database-y things. Also found some things out about the process that were a little undocumented/misdocumented (now a word).
The biggest issue (so far) was file uploads. So here’s a quick tutorial on how to do file uploads with perl, with mason.
In index.html (or wherever your form HTML code lives):
1
2
3
4
| <form method="post" action="upload.mas" enctype="multipart/form-data">
<input type="file" name="file_name" /><br />
<input type="submit" value="Submit" />
</form> |
In upload.mas:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| <%init>
use Apache2::Upload;
# $r is an Apache2::RequestRec, not an Apache2::Request like some places say it is
my $req = Apache2::Request->new($r);
# file_name refers to the form name you had in your HTML
my $upload = $req->upload('file_name');
my $fh = $upload->fh;
open OUTFILE, ">$where_ever_you_wanna_save_the)file";
binmode $fh;
binmode OUTFILE;
print OUTFILE $line foreach my $line (<$fh>);
close OUTFILE;
close $fh;
</%init> |
In your httpd.conf:
APREQ2_READLIMIT 2G # Sets the max size of your user's uploads to 2GB
I intentionally skipped over error handling code and all of the httpd.conf config for the sake of brevity (I did say brief tutorial). Since I need to allow for larger file sizes than Apache does by default (64MB), I spent quite some time looking for that Apache directive.
Hopefully this saves someone some time.