Hi All,
my html code is sno 1) and perl code is sno 2).
a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it didnt display the html after the perl script executed. Using perl 5.1 and apache 2.2.9 version(apache installed and run without any errors and no warning, perl tested fine)
b) Also, when i clicked the html code to submit the upload of the file, the browser would prompt me to open the perl script, and not it let run in the background which I expected it to be.
Kindly assist!!
Thanks,
Andrew
1) html code - tml>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>File Upload</title>
-
</head>
-
<body>
-
<form action="/perl/bin/upload.pl" 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>
-
</body>
-
</html>
2) - #!d:\perl\bin\perl.exe -w
-
package HelloWorld;
-
-
use test-strict;
-
use CGI;
-
#use CGI::Carp-Debug qw ( fatalsToBrowser );
-
#use File::Basename-Object;
-
-
$CGI::POST_MAX = 1024 * 5000;
-
my $safe_filename_characters = "a-zA-Z0-9_.-";
-
my $upload_dir = "d:\uploaded";
-
-
my $query = new CGI;
-
my $filename = $query->param("photo");
-
my $email_address = $query->param("email_address");
-
-
if ( !$filename )
-
{
-
print $query->header ( );
-
print "There was a problem uploading your photo (try a smaller file).";
-
print "CGI - $CGI::POST_MAX";
-
print "safe - $safe_filename_characters ";
-
print "photo - $filename ";
-
-
-
print "Press the ENTER key to exit program ...";
-
$pause = <STDIN>; #Like a PAUSE statement in DOS .bat files
-
-
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("photo");
-
-
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>
-
<style type="text/css">
-
img {border: none;}
-
</style>
-
</head>
-
<body>
-
<p>Thanks for uploading your photo!</p>
-
<p>Your email address: $email_address</p>
-
<p>Your photo:</p>
-
<p><img src="/upload/$filename" alt="Photo" /></p>
-
</body>
-
</html>
-
END_HTML
-
-
-
-
#exit;
Sep 28 '08
66 8104
hi all,
The apache error log is below, I think i followed most of the guidelines,,, not sure what is the real issue?
Thanks again,
Andrew
[Fri Jan 30 23:40:59 2009] [error] [client 127.0.0.1] email() failed: Mail::Sender::Error: Connection not established at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/send3.pl line 10.\r
[Fri Jan 30 23:41:13 2009] [error] [client 127.0.0.1] email() failed: Mail::Sender::Error: Connection not established at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/send3.pl line 10.\r
[Fri Jan 30 23:42:12 2009] [error] [client 127.0.0.1] email() failed: Mail::Sender::Error: Connection not established at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/send3.pl line 10.\r
[Fri Jan 30 23:54:03 2009] [error] [client 127.0.0.1] email() failed: Mail::Sender::Error: Connection not established at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/send4.pl line 10.\r
hihi,
Any body can kindly assist on the above... really desperate for some advises.. thanks in advance...
Andrew
@happyse27
hi all
the apache logs are below... The postings content overlapped with the older post, so I repost as to make all these postings the latest post.
I need kind assistance to resolve the email problem... thanks in advance...
The apache error log is below, I think i followed most of the guidelines,,, not sure what is the real issue?
[Fri Jan 30 23:40:59 2009] [error] [client 127.0.0.1] email() failed: Mail::Sender::Error: Connection not established at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/send3.pl line 10.\r
[Fri Jan 30 23:41:13 2009] [error] [client 127.0.0.1] email() failed: Mail::Sender::Error: Connection not established at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/send3.pl line 10.\r
[Fri Jan 30 23:42:12 2009] [error] [client 127.0.0.1] email() failed: Mail::Sender::Error: Connection not established at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/send3.pl line 10.\r
[Fri Jan 30 23:54:03 2009] [error] [client 127.0.0.1] email() failed: Mail::Sender::Error: Connection not established at D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/send4.pl line 10.\r KevinADC 4,059
Recognized Expert Specialist
Do you have a firewall running? Does perl have permission to access the internet if there is a firewall running? Are you sure this is correct: 'smtp' => 'ssl://smtp.gmail.com',
Maybe ssl should be http or https?
hi kevin,
no firewall as I did send before, i tried with ssl, http and https, did not work...
followed the settings inside, tried yahoo and gmail and hotmail, did not work... does it ever work?
Cheers...
Andrew
numberwhun 3,509
Recognized Expert Moderator Specialist @KevinADC
Andrew,
In addition to what Kevin wrote above, you may want to take a look at this Gmail Help page. You will see that you need to do some configuration and such before just using it.
Regards,
Jeff
tried the settings about the ssl, did not work...
getting desperate for this case...
tried the instructions given by gmail... which did not work
numberwhun 3,509
Recognized Expert Moderator Specialist @happyse27
In the link that you provided, did you happen to notice that for the gmail smtp address, they use a non-standard port for the ssl? They are using port 465. The standard ssl port is 443, so you will have to specify that somehow in the url -
$smtp => 'smtp.google.com:465'
-
I can only assume that the prefix on the URL will be either http or https. I don't think that ssl is a prefix. At least I have never seen it used.
Regards,
Jeff
changed... :465 still cant work... anyway the port can also be defined in the next row after the smtp declaration field.
Still cant work, kindly assist... cheers...
numberwhun 3,509
Recognized Expert Moderator Specialist @happyse27
Did you change the "ssl" to something like "https"? "ssl" isn't a protocol to precede a URL as you have done.
KevinADC 4,059
Recognized Expert Specialist
Sorry, I can't help anymore than I already have tried to.
hi kevin / all,
It is fine, thanks..
1) I just wanted to know, for mail::sender module, how to include ssl and even starttls in the perl script as the documentation of mail::sender module did not specify how to configure ssl or even starttls..
2) telnet smtp.gmail.com 465 did help.
3) http://www.perlmonks.org/?viewmode=p...node_id=359731 is where tls can be configured...
4)testing with outlook express worked... http://mail.google.com/support/bin/a...y?answer=76147
Thanks in advance,
Andrew
item 1 found sample code below fior item 3 above
======================== -
use Mail::Sender;
-
-
my $params = {
-
smtp=> 'bleargh.foo.com', #'mail6.ignum.cz',
-
to => 'jenda@krynicky.cz',
-
subject => 'Mail::Sender.pm - test TLS',
-
charset => 'windows1252',
-
TLS_required => 1,
-
auth => 'PLAIN',
-
authid => 'yyy',
-
authpwd => 'xxx',
-
debug => \*STDERR,
-
msg => <<'*END*'};
-
numberwhun 3,509
Recognized Expert Moderator Specialist @happyse27
Andrew,
I am not really sure as I have not played with the module that you are referencing. I have sent mail using Perl before, using the Mail::Sendmail module, but have never done anything using SSL to send the mail (this is typically because the mails were all internal and didn't need encryption or encrypted transport).
I would suggest, if nobody here can help, that you post onto the Perlmonks site, as they probably have an answer for you on this. Please know though, if you have never posted over there, that they are rather particular about having all questions properly formed and asked.
Regards,
Jeff
Icecrack 174
Recognized Expert New Member
Hi Andrew,
First this Notice from the Cpan Module:
GOTCHAS
Local user "someone@somewhere.com" doesn't exist
"Thanks" to spammers mail servers usualy do not allow just anyone to post a message through them. Most often they require that either the sender or the recipient is local to the server
Mail::Sendmail works, Mail::Sender doesn't
If you are able to connect to the mail server and scripts using Mail::Sendmail work, but Mail::Sender fails with "connect() failed", please review the settings in /etc/services. The port for SMTP should be 25.
Second try adding more debug/error reporting:
Third Check You INSTRUCTIONS THAT COME WITH THE MODULE Mail::Sender:
auth
the SMTP authentication protocol to use to login to the server currently the only ones supported are LOGIN, PLAIN, CRAM-MD5 and NTLM.
Some protocols have module dependencies. CRAM-MD5 depends on Digest::HMAC_MD5 and NTLM on Authen::NTLM.
You may add support for other authentication protocols yourself. See below.
Here are the return codes for errors: - Return codes
-
-
ref to a Mail::Sender object = success
-
-
-1 = $smtphost unknown
-
-2 = socket() failed
-
-3 = connect() failed
-
-4 = service not available
-
-5 = unspecified communication error
-
-6 = local user $to unknown on host $smtp
-
-7 = transmission of message failed
-
-8 = argument $to empty
-
-9 = no message specified in call to MailMsg or MailFile
-
-10 = no file name specified in call to SendFile or MailFile
-
-11 = file not found
-
-12 = not available in singlepart mode
-
-13 = site specific error
-
-14 = connection not established. Did you mean MailFile instead of SendFile?
-
-15 = no SMTP server specified
-
-16 = no From: address specified
-
-17 = authentication protocol not accepted by the server
-
-18 = login not accepted
-
-19 = authentication protocol is not implemented
Sign in to post your reply or Sign up for a free account.
Similar topics
by: G Kannan |
last post by:
Hey all!
I have written a perl script to retrieve information from a HTML Form
and insert the data into an Oracle database table. I am gettting the
the following error message:
"Use of...
|
by: rk |
last post by:
Hi,
I'm a beginner for perl/cgi programs and i tried to write a cgi script
and when i ran it, i got the following error. But when i verified it
from the book i typed exactly whatever it is there...
|
by: Peter Morris |
last post by:
Is it possible to use C or C++ to create web pages?
Ouputting text with HTML syntax is easy enough,
but how do I make a web browser see the generated
text?
|
by: Sherman Willden |
last post by:
I am trying to use Perl's XML::Twig to modify a version number in an
XML document. At the very end of this posting is an excerpt from the
xml document. Just before the xml excerpt is the Perl code...
|
by: Treetop |
last post by:
I would like to pass text to a popup window to save creating a new
html file for each help topic.
I would like to have a value for the heading, a value for the text,
code for printing the help...
|
by: supern |
last post by:
#!c:/perl/bin/perl.exe
$basedir="c:/program files/apache software foundation/apache2.2/cgi-bin";
$datafile="regstr.txt";
$name=$in{'login'};
$passwd=$in{'passwd'};
open(FH1,"+>>regstr.txt");...
|
by: pleaseexplaintome |
last post by:
Hi I have the following perl/cgi script snippet. The goal of this
script is to pass a javascript variable to perl where it can be re-used
later. Any help is appreciated, Thanks
...
|
by: Mariusf |
last post by:
I am a novice Perl programmer and need to change a perl script that I use to create web pages with thumbnail images and some text. Currently the script created a web page for each artist / category...
|
by: roop1 |
last post by:
I am using a perl script to produce a six element array. When I click a string in the first element, I am linked to a html table (all.html) and the matching string is displayed in the first row of...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |