uploading files

D

D Borland

Hi again folks,

I'm trying to get the script below to work. I've checked it's syntax and
perl says that it's ok, i cannot check the logs on the server as 1&1
webhosting don't seem to allow me that, as when i run the script i get a
server 500 error, with no info on why :( I've checked to see if the script
still managed to upload the file which it did... any ideas?

Thanks for your time.

__CODE__

#!/usr/bin/perl

use strict;
use warnings;

use CGI;
use CGI::Carp 'fatalsToBrowser';

$CGI::pOST_MAX = 1024 * 500;

my $query = new CGI;

my $filename = $query->param('image1');
my $fileToUpload = $query->upload('image1');
my $uploadDir = "$ENV{'DOCUMENT_ROOT'}/beta";

$filename =~ s/.*[\/\\](.*)/$1/;

open(NEWFILE, ">$uploadDir/$filename")
or die "Cannot create new file $uploadDir/$filename : $!\n";

binmode(NEWFILE);

while (<$fileToUpload>) {
print NEWFILE;
}

close(NEWFILE);

print $query->p("File uploaded");

__END__
 
D

D Borland

ooops! :)

Forgot to print the header first, guess i was just looking at it too long,
and just didn't see it until i sat back for a bit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top