Basically I have created a form which can be viewed at www.icomworks.co.uk/canvaspayform.html
I want to submit the form along with the file so that they are both placed on my server... I have created a folder on my server in my public_html called myscripts and have saved my upload.cgi script into that folder. my form points to that script but when I fill in the form and submit the form I get the following error message.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@icomworks.co.uk and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
I have given the folder which the script is in the right permissions (755) and I have the upload path "i think" pointing to the right folders..
here are the code for the form and the script
Expand|Select|Wrap|Line Numbers
- <form name="contactdet" action="myscripts/upload.cgi"method="post" onSubmit="return validate_form ( );" enctype="multipart/form-data">
- <p>First name: <input type="text" name="name1" id="name1" size="20"/></p>
- <p>Last name: <input type="text" name="name2" id="name2" size="20"/></p>
- <p>Email address:<input type="text" name="email" id="email_address" size="20" /></p>
- <p>Contact number:<input type="text" name="phone" id="phone" size="20"/></p>
- <p>House number: <input type="text" name="housenum" id="housenum"/></p>
- <p>Address 1:<input type="text" name="add1" id="add1" /></p>
- <p>Address 2:<input type="text" name="add2" id="add2" /></p>
- <p>Town:<input type="text" name="town" id="town" class="town"/></p>
- <p>Post code:<input type="text" name="pcode1" id="pcode" size="10" class="pcode1"/></p>
- <p>Picture upload:<input type="file" name="photo" /></p>
- <p><input type="submit" name="submit" value="Upload Canvas Image" /></p></form>
and this is the cgi script I created:
Expand|Select|Wrap|Line Numbers
- #!/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 ="public_html/canvasimages";
- 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)."; *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;
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> *<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
Im using an apache server and I use a mac to make the forms and script
I'm sorry the spacing is not right when i pasted the code into the boxes they displayed all together... i've tried to break it up a bit to make it more understandable..
thnaks for taking the time to read this
Owain