Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

File upload via web form

File upload via web form

File upload via web form

I've been trying to do a file upload via a web form so that a user can post a file to a web directory from a web form. I've banged my head against javascript for a while and no luck (I think due to security). I've seen plain form submissions to a directory via a web form using perl, can I also use it to post a file to the same directory (much like a bulliten board)? Any help would be most appreciated as my perl skills are not up to par for web programming...


RE: File upload via web form


Well, being new to Perl, and presently wtill working on honing my JavaScript, dHTML, and now HTML 5.0 skills I can't help you much with the Perl part of this. BUT I can give you the HTML that you'll need for it:
(inside your <form> and </form> tags put the following where you'd like to allow users to do their file upload):
<input type=file>
(and if you really want to make things a little easier on your clients, e-mail me,and I can design you a JavaScript to check thier http file uploading capabilities)


RE: File upload via web form

I'm also a newbie to Perl, but in the CGI module (use CGI), there's a File upload function which may be able to do what you are after.
I haven't tried it myself, but the documentation should provide an example or two (man perlcgi or man CGI, I can't remember which)


RE: File upload via web form


I have been working with perl for sometime now,

What you will need is a form with a <input type='file' name='blah'> in it and this submitting to a cgi where you need to get the value of the input field and run this command:

while ($size = read($upload_file,$buffer,1024)) {
print FILE $buffer;
$total_size = $size;

The variable $upload_file is the value of the input field from the previous form, you may find that you have some problems with this but just make sure that your permissions are set so that the httpd user can write to the directory you are trying to write to.  BTW FILE is a filehandle for the location that you are trying to write to.

If you want more info drop us an email.

RE: File upload via web form

There are two FAQs on this topic at faq219_406 and faq219_352.  The first uses CGI.pm and the second uses cgi-lib.pl or CGI_Lite.pm.  

'hope this helps...

 keep the rudder amid ship and beware the odd typo

RE: File upload via web form

I really thought those two faq ids were going to show up as links.  Since they did not, just click the FAQ tab at the top of the Perl forum front page and look for the FAQs on  uploading files.  I think they are number 7, maybe.


 keep the rudder amid ship and beware the odd typo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close