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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI Error

Status
Not open for further replies.

jaffa84

Technical User
Mar 2, 2005
4
GB
Im getting this when im trying to uploadfiles!! new to programming can anyone help me! really stuck now tryed lots of things with no result!!

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
 
you might be trying to print something to the browser without first printing a header. If using CGI.pm you print a header like this:

print header();

or:

print $query->header();

depending on the method you are using, if not you can do this:

print "Content-type: text/html\n\n";


before any prints to the browser (but not cookies). I recommend you read the CGI.pm documentation.

 
Here is a view of the code!! whats wrong still dont get it!!

#1/usr/local/bin/perl -wT
use strict;
use CGI ':standard';

print "content-type: text/html\n\n";

my $file = param ('uploadfile');
my $info = uploadinfo ($file);
my $type = $info -> {'content-Type'};

if ($file) {
open (UPLOAD, ">ukhoneyz.co.uk/photos/uploadfile")

my($data, $length, $chunk);
if($length > 51200) {
print "That file is too big. The limit is 100K.";
exit;
}

}
close (UPLOAD);

print "<p>You uploaded <b>$file</b>
which had a MIME type of
<b>$type</b>.";

)else {
print "No file was chosen.";
}

sub error {
print "Couldn't open tempoary file:
$!";
exit;
 
Your content type header is incorrect, as is your shebang [#!] line

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

instead of that print statement, replace with

Code:
$q=new CGI;
print $q->header();

HTH
--Paul

cigless ...
 
right ive now got this and it still not working to have a look for you rself goto
$q=new CGI
print $q->header();
use strict;
use CGI':standard';

print "content-type: text/html\n\n";

my $file = param ('uploadfile');
my $info = uploadinfo ($file);
my $type = $info -> {'content-Type'};

if ($file) {
open (UPLOAD, ">
my($data, $length, $chunk);
if($length > 51200) {
print "That file is too big. The limit is 100K.";
exit;
}

}
close (UPLOAD);

print "<p>You uploaded <b>$file</b>
which had a MIME type of
<b>$type</b>.";

)else {
print "No file was chosen.";
}

sub error {
print "Couldn't open tempoary file:
$!";
exit;
}
 
Jaffa,

Have a look at the sample upload scripts here in the FAQ section, and also over in the Perl forum.

There's too many issues to try anbd sort out in one sitting.

Check those out and get back if you have an issue

--Paul

cigless ...
 
ok will do!! thanks for trying to help!!
 
Why try to re-invent the wheel? Go to:

Click the radio button "Upload Light"

It is well documented, simple to use (you only need to modify like 10 extremely common sence lines) and it workes on every platform. It has many advanced features too, and is 100% free.

Make sure you:
- Place this line in the opening <form> tag:
enctype="multipart/form-data"

- CHMOD the folders the files upload to:
777

- Everything else that pertains to CGI scripts and is listed on the install instructions and you will have no problems

If you have questions about this scrip there is documentation on the web site.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top