Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I know someone is going to laugh when they read this question, but I am trying to create a web site that makes life really easy on this one group on campus to upload Word Documents up to a campus web server... I have never done a form upload before and it's really starting to piss me off... the upload part of the code is:

$file_name = param('file_name'); &save_file; &Print_Error if($file_name eq ""); &Return_html; sub save_file { open (MYFILE, ">/user/s4/kendo/public_html/write/$file_name" ) + || die $!; while(<$file_name>){ print MYFILE $_; } close(MYFILE); } sub Return_html { print header(); print start_html('Upload Complete'); print "<h1>Your upload is complete!</h1>"; print "$file_name"; print end_html; } sub Print_Error { print header(), start_html('Upload Error!'); print "<p>Field \'File Name\' must be filled in for this script to work properly.</p>\n"; print end_html; exit 0; }
Any kind of help would be greatly appreciated...

Replies are listed 'Best First'.
Re: File Upload through a form
by Trimbach (Curate) on Oct 28, 2000 at 23:16 UTC
Re: File Upload through a form
by tune (Curate) on Oct 29, 2000 at 19:59 UTC
    Or 'man CGI' should help if you missed something at the uploader form. First the manual, then question archives, then you can yell for help :-)

    -- tune

Re: File Upload through a form
by Fastolfe (Vicar) on Oct 30, 2000 at 20:02 UTC
    Please elaborate on what exactly you're having problems when. Posting a partial code snippet and saying "it doesn't work" doesn't allow us to help you at all. The CGI documentation has a complete section with examples on doing file uploads, as well as a few caveats, one of which is probably your problem.

    If you're still having problems, explain what is wrong, what is happening, and show us how you're building your HTML form.