Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't find string terminator "END_HTML" anywhere before EOF

Status
Not open for further replies.

JackTheRussel

Programmer
Aug 22, 2006
110
FI
Hi.

I found nice picture upload script, but it wont work.
When I choose picture to upload and push the send button, nothing happens. The screen is just white.

When I look to the error-file I found these errors:
Code:
[Mon Oct 08 14:18:10 2007] [error] [client 127.0.0.1] Can't find string terminator "END_HTML" anywhere before EOF at /var/[URL unfurl="true"]www/cgi-bin/upload.cgi[/URL] line 26., referer: [URL unfurl="true"]http://localhost/upload.html[/URL]

[Mon Oct 08 14:18:10 2007] [error] [client 127.0.0.1] Premature end of script headers: upload.cgi, referer: [URL unfurl="true"]http://localhost/upload.html[/URL]

I'm totally newbie in CGI, so any help would be nice.

Here is the cgi-script code:
Code:
#!/usr/bin/perl -w

 use CGI;

 $upload_dir = "/var/[URL unfurl="true"]www/html/upload";[/URL]

 $query = new CGI;

 $filename = $query->param("photo");
 $email_address = $query->param("email_address");
 $filename =~ s/.*[\/\\](.*)/$1/;
 $upload_filehandle = $query->upload("photo");

 open UPLOADFILE, ">$upload_dir/$filename";

 binmode UPLOADFILE;

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

 close UPLOADFILE;

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

 <HTML>
 <HEAD>
 <TITLE>Thanks!</TITLE>
 </HEAD>

 <BODY>

 <P>Thanks for uploading your photo!</P>
 <P>Your email address: $email_address</P>
 <P>Your photo:</P>
 <img src="/var/[URL unfurl="true"]www/html/upload/$filename"[/URL] border="0">

 </BODY>
 </HTML>

    END_HTML;

And here is the upload.html
Code:
<HTML>
 <HEAD></HEAD>
 <BODY>
 <FORM ACTION="/cgi-bin/upload.cgi" METHOD="post" ENCTYPE="multipart/form-data">
 Photo to Upload: <INPUT TYPE="file" NAME="photo">
 <br><br>
 Your Email Address: <INPUT TYPE="text" NAME="email_address">
 <br><br>
 <INPUT TYPE="submit" NAME="Submit" VALUE="Submit Form">
 </FORM>
 </BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top