Closing Doman Auctions
DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars
HomeRegisterMembershipsGetting StartedDomain Tools Domain EbooksSEO Software Domain Resellers Advertise

Go Back   DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars > Content Development > Website Development and Design Discussion > Coding/Programming/Languages
Register Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old 07-12-2008, 12:50 AM   #1 (permalink)
DNF Addict
 
$ideline's Avatar
 
Name: Angela
Last Online: Yesterday 12:29 PM
iTrader: (21)
Join Date: Mar 2007
Posts: 489
DNF$: 4,629
Location: Canada
Country:


Please help with this cgi upload script!

Hi guys, I keep getting the error message :"Can't find string terminator "END_HTML" anywhere before EOF at upload.cgi line 53" and I am at my wits end trying to fix this one.

Here is the script - if anyone has any suggestions fire them at me, I'll try just about anything right now. Thanks


#!/usr/bin/perl -wT

use strict;
use CGI;
use CGI::Carp qw ( fatalsToBrowser );
use File::Basename;

$CGI:OST_MAX = 1024 * 5000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "http://www.photodesktops.ca/upload";

my $query = new CGI;
my $name = $query->param("name");
my $location = $query->param("location");
my $email = $query->param("email");
my $photolocation = $query->param("photolocation");
my $filename = $query->param("uploadfile");

if ( !$filename )
{
print $query->header ( );
print "There was a problem uploading your photo (try a smaller

file).";
exit;
}

my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;

if ( $filename =~ /^([$safe_filename_characters]+)$/ )
{
$filename = $1;
}
else
{
die "Filename contains invalid characters";
}

my $upload_filehandle = $query->upload("uploadfile");

open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!";
binmode UPLOADFILE;

while ( <$upload_filehandle> )
{
print UPLOADFILE;
}

close UPLOADFILE;

print $query->header ( );
print <<END_HTML;

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"

/>
<title>Thanks!</title>
</head>
<body>

<p>Thanks for uploading your photo!</p>
<p>Your email address: $email</p>
<p>Your photo:</p>
<p><img src="http://www.photodesktops.ca/upload/$filename"

alt="Photo" border="0"></p>
</body>
END_HTML
;
__________________
DNshop.ca -- shop for .ca domains

Domainatrix.ca -- No Tricks... Just Domains
$ideline is offline   Reply With Quote
Sponsored Ads
Old 07-12-2008, 02:14 AM   #2 (permalink)
Platinum Lifetime Member
 
Area52's Avatar
 
Last Online: Today 05:25 AM
iTrader: (4)
Join Date: Mar 2006
Posts: 310
DNF$: 2,135
Location: US
Country:


Code:
</body>
</html>
END_HTML
;
Area52 is offline   Reply With Quote
Old 07-12-2008, 10:32 PM   #3 (permalink)
DNF Addict
 
$ideline's Avatar
 
Name: Angela
Last Online: Yesterday 12:29 PM
iTrader: (21)
Join Date: Mar 2007
Posts: 489
DNF$: 4,629
Location: Canada
Country:


k i'll try it.... had it that way before and was still not working but could have been due to other stuff that I was working on at the same time.

now getting error msg - No such file or directory at upload.cgi line 42.
__________________
DNshop.ca -- shop for .ca domains

Domainatrix.ca -- No Tricks... Just Domains

Last edited by $ideline; 07-12-2008 at 10:53 PM.. Reason: Automerged Doublepost
$ideline is offline   Reply With Quote
Old 07-13-2008, 06:58 AM   #4 (permalink)
Platinum Lifetime Member
 
Area52's Avatar
 
Last Online: Today 05:25 AM
iTrader: (4)
Join Date: Mar 2006
Posts: 310
DNF$: 2,135
Location: US
Country:


Try this
Code:
my $upload_dir = "http://www.photodesktops.ca/upload";
The highlighted path to the uploaded file storage directory needs to be the absolute server path. Varies depending on your host.
Also, user permissions (chmod if your using Linux) must be set for that directory that will enable the script to read and write to it.
Depends on your host configuration.



Code:
#!/usr/bin/perl -wT     

use strict;
use CGI;
use CGI::Carp qw ( fatalsToBrowser );
use File::Basename;

$CGI::POST_MAX = 1024 * 5000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "http://www.photodesktops.ca/upload";          

my $query = new CGI;
my $name = $query->param("name");
my $location = $query->param("location");
my $email = $query->param("email");
my $photolocation = $query->param("photolocation");
my $filename = $query->param("uploadfile");

if ( !$filename )
{
print $query->header ( );
print "There was a problem uploading your photo (try a smaller file).";
exit;
}

my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;

if ( $filename =~ /^([$safe_filename_characters]+)$/ )
{
$filename = $1;
}
else
{
die "Filename contains invalid characters";
}

my $upload_filehandle = $query->upload("uploadfile");

open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!";
binmode UPLOADFILE;

while ( <$upload_filehandle> )
{
print UPLOADFILE;
}

close UPLOADFILE;

print $query->header ( );
print <<END_HTML;

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thanks!</title>
</head>
<body>
<p>Thanks for uploading your photo!</p>
<p>Your email address: $email</p>
<p>Your photo:</p>
<p><img src="http://www.photodesktops.ca/upload/$filename" alt="Photo" border="0"></p>
</body>
</html>
END_HTML
Area52 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:35 PM.
Copyright @2001-2009 DNForum.com