in reply to
How to upload file without using FTP?
You can use many different things to upload it... lwp, wget, curl, or even pure sockets. Here is an lwp based uploader with a Tk front-end -> tk-http-file-upload-w-progress You can rip out the Tk code if you want, and have a console app
Here is the cgi which receives it.
#!/usr/bin/perl
use warnings;
use strict;
use CGI;
use CGI::Carp 'fatalsToBrowser';
#my $maxsize = 1024 * 100; #max 100K
my $maxsize = 1024 * 20000; #max 20M
#$CGI::POST_MAX= $maxsize; # max 100K posts !not working right?
#$CGI::DISABLE_UPLOADS = 1; # no uploads
my $query = new CGI;
my $upload_dir = "uploads"; #permissions for dir are set
print $query->header();
if($ENV{CONTENT_LENGTH} > $maxsize){
print "file too large - must be less than $maxsize bytes";
exit;
}
my $file = $query->param("file");
my $filename = $file;
$filename =~s/.*[\/\\](.*)/$1/;
open (UPLOADFILE, ">$upload_dir/$filename");
$/= \8192; # sets 8192 byte buffer chunks, perldoc perlvar
while ( <$file> ){
print UPLOADFILE $_;
#select(undef,undef,undef,.05); #for testing
}
close UPLOADFILE;
print <<END_HTML;
<HTML>
<HEAD> <TITLE>Thanks!</TITLE> </HEAD>
<BODY bgcolor="#ffffff"><br>
<P>Thanks for uploading file : $filename!</P>
</BODY>
</HTML>
END_HTML
I'm not really a human, but I play one on earth.
flash japh