Make sure there's no whitespace before the terminating END_HTML marker - the E must be the first character on the line.Originally Posted by HELPTony
Make sure you uploaded the file in ASCII (text) mode.
Matt
| SitePoint Sponsor |

Make sure there's no whitespace before the terminating END_HTML marker - the E must be the first character on the line.Originally Posted by HELPTony
Make sure you uploaded the file in ASCII (text) mode.
Matt
I am using an opera browser and when running the upload.cgi script what happens is that i recievce the whole script printed on the browser, what am i doing wrong ?
great article, but I am getting an internal server error (500). I have checked the permissions and made sure that the paths are correct and uploaded in ASCII. The file is at prettyshady.com/upload. Thanks

Your site/server (or the folder where you've uploaded the script) isn't set up to run CGI scripts, and/or you haven't set execute permission on the script.Originally Posted by amos

Look in your server's error log for the actual error message, or run the script from the shell prompt to debug.Originally Posted by ben
You can find more info on troubleshooting CGI scripts in this tutorial on our site.
Hope that helps!
Matt
How can I set an execute permission to file?

chmod a+x <filename>
Also try this tutorial.
Cheers,
Matt
thanks for the response but i have exec permissions on the script do you have another idea to the result i am getting ( amos from before )
thanks!
Wonderful script and great writing style and explanation of things.
few questions:
1) How do I restrict the file size of the icture being uploaded to 120K
2) How do I restrict file types to .jpg, .tif, .bmp
I really like your tutorial but I'm getting a error when I hit the submit button.
it says"
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request
I would appreciate any help I can get thank you!
Hi tsears, I changed $upload_dir = whatever; to $upload_dir = "."; for the time being. I will add code so that it makes a new folder for each user soon. Also dont forget to change your upload.cgi file permision to 755! I am not sure how secure this method is as yet, but I am going to look into it all, and may be writing a more advanced version of my own. This will include an upload file size limiter, for more info write to cgi@thelenches.co.uk, have fun!
For a client on my website to have the facilty to upload 8-10 photos at once, and also for them to have password entrance so as not to create confusion with clients with same name and photo uploads.
How can I expand on the script that you have supplied here?
Cheers.
netbroker
thx for nice post
Hi,
I read ur article and it helped me a lot.Right now i am facing a problem with the code.I used the code to upload the file which is not a binary file and i wrote a upload.cgi script and when i run the script i get a error- Undefined subroutine CGI::upload. Can you please suggest me a solution.
Regards,
Deepa
i want to store word file in mysql using perl
Nice Work! Too bad it didn't work for my AOL website. I must have some path missing or not conforming to the AOL cgi-bin format. I uploaded the cgi script to the AOL website directory which is http://hometown.aol.com/Djosepa2z/upload.cgi.
as instructed and named it upload.cgi and its upload_dir reads as: $upload_dir = "/hometown.aol.com/Djosepa2z/fileupload";
I created an upload and uploaded it to the same website directory. It url is http://hometown.aol.com/Djosepha2z/upload
I uploaded the HTML form page to the same website directory and named it fileupload and its url is http://hometown.aol.com/Djosepa2z/fileupload.htm and this is how its Form Action reads: <FORM ACTION="/cgi-bin/formupload/upload.cgi/Djosepa2z" METHOD="post" ENCTYPE="multipart/form-data">
Something is still off. It didn't work. I rate your article as excellent! Thanks for the info.
I did try this and it's good and easy to understand. But until now when i try to 'submit form'.. this error occured--->The page cannot be displayed
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings. I'm not sure either it's my CGI file setup wrongly. Please help.......
i followed all of it, chmoded everything correctly, madesureall of the info was correct, and it fgives me a 500 internal server error evertime i hit submit. it is borked.
Everything checked and double checked but I'm not getting anything from the $query->param("photo") line. It claims there is no value for photo.
Parsing paths using regular expressions is potentially dangerous. It's much safer to use the splitpath function from the File::Spec module which can be used to extract a filename from a path when called like so:
use File::Spec;
...
# File::Spec returns volume name, path, filename - we only want filename
(undef, undef, $filename) = File::Spec->splitpath($filename);
If the $filename variable is only the filename itself, this call will leave it as-is.
cgi scripts have no permission to write on the document root. Any suggestions on how to make the file visible?
Would this program work as well?Originally Posted by elated
Code:#!/usr/bin/perl use Cwd; $dir = cwd; print "content-type: text/html\n\n"; print $dir;
Did you note the date of bbmonkeys post?The problem isnt in perl script but in HTML. Your tag FORM miss or has wrong method attribute. set method="POST" and enjoy uploading.
nice
Bookmarks