Thanks fro the welcome Phranque
Answers:
Yes,yes
I think so...
I can't see anything from the log files really indicating what is wrong!
This is the Form HTML:
<form action="/cgi-bin/upload.cgi" method="post"
enctype="multipart/form-data">
<p>Photo to Upload: <input type="file" name="photo" /></p>
<p>Your Email Address: <input type="text" name="email_address" /></p>
<p><input type="submit" name="Submit" value="Submit Form" /></p>
</form>
And this is the CGI script:
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
use File::Basename;
# set the maximum limit for file uploads
$CGI::POST_MAX = 1024 * 5000;
# change to 1 (one) to disable file uploads
$CGI::DISABLE_UPLOADS = 0; #1 disables uploads, 0 enables uploads
my $query = new CGI;
unless ($CGI::VERSION >= 2.47) {
print $query->header(),
$query->start_html(),
'Your version of CGI.pm is too old. You must have verison 2.47 or higher to use this script.',
$query->end_html;
exit(0);
}
my $upload_dir = "/home/MYHOST/MYWEBSITE/user/htdocs/upload";
# a list of valid characters that can be in filenames
my $filename_characters = 'a-zA-Z0-9_.-';
my $file = $query->param("photo");
my $email_address = $query->param("email_address");
# get the filename and the file extension
# this could be used to filter out unwanted filetypes
# see the File::Basename documentation for details
my ($filename,undef,$ext) = fileparse($file,qr{\..*});
# convert spaces to underscores "_"
$filename =~ tr/ /_/;
# remove illegal characters
$filename =~ s/[^$filename_characters]//g;
# append extension to filename
$filename .= $ext;
# satisfy taint checking
if ($filename =~ /^([$filename_characters]+)$/) {
$filename = $1;
}
else{
print $query->header(),
$query->start_html(),
'The filename is not valid. Filenames can only contain these characters: $filename_characters',
$query->end_html;
exit(0);
}
my $upload_filehandle = $query->upload("photo");
open (UPLOADFILE, ">$upload_dir/$filename") or die "$!";
binmode UPLOADFILE;
while ( <$upload_filehandle> ) {
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header(),
$query->start_html(-title=>'Upload Successful'),
$query->p('Thanks for uploading your photo!'),
$query->p("Your email address: $email_address"),
$query->p("Your photo $filename:"),
$query->img({src=>"../uploads/$filename",alt=>''}),
$query->end_html;
(MY HOST and MYWEBSITE changed to protect the innocent!)
Thanks in advance
SF