in reply to CGI File Upload
I don't know if you are still around...
I think that you mean upload a file through a web browser and put it in a certain directory?
I am doing a similar thing so I found http://www.webmasterbase.com/article/474 however I can't get it to work quite right so someone else may help. I get zero sized files. and an error message in the logs.
It seems that the follwing line is failing in my codereadline() on unopened filehandle at /var/www/admin/upload.cgi line 27.
my $upload_filehandle = $query->upload("myfilename");
myfilename is the name of the
This is the upload script<input type=file name="myfilename" ENCTYPE="multipart/form-data">
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $upload_dir = '/var/vhosts/www.woodheap.org/admin/incoming';
my $query = new CGI;
my $filename = $query->param('myfilename');
print $filename;
$filename =~ s/.*\/\\(.*)/$1/;
print $filename;
chmod 0777, "$filename";
my $upload_filehandle = $query->upload("myfilename");
open(UPLOADFILE, ">$upload_dir/$filename") or die $!;
chmod 0777, "$upload_dir/$filename";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: CGI File Upload
by BrowserUk (Patriarch) on Sep 09, 2002 at 02:45 UTC | |
by blm (Hermit) on Jan 15, 2006 at 12:32 UTC |