Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

I need a script for web file uploading.

by Anonymous Monk
on Jun 13, 2000 at 20:17 UTC ( #17909=categorized question: print w/replies, xml ) Need Help??
Contributed by Anonymous Monk on Jun 13, 2000 at 20:17 UTC
Q&A  > CGI programming

Answer: I need a script for web file uploading.
contributed by cLive ;-)

Here's a simple example script.

#!/usr/bin/perl -w use strict; # make html/forms easy to deal with use CGI; # report errors in the browser # (remove from production code) use CGI::Carp 'fatalsToBrowser'; # create new CGI object my $q = new CGI; if ( ! $q->param() ) { # first run, so present form print $q->header, $q->start_html, $q->start_multipart_form, $q->filefield('file'), $q->br, $q->submit('Upload'), $q->end_form, $q->end_html; } else { # file uploaded, so process it # read filehandle from param and set to binary mode my $filehandle = $q->param('file'); binmode $filehandle; # open file for output. Change this to suit your needs!!! open OUT, "> /path/to/local/filename" or die $!; binmode OUT; # process $filehandle { my $buffer; while ( read $filehandle, $buffer, 1024 ) { print OUT $buffer; } } close OUT; # show success print $q->header, $q->start_html, $q->p('File uploaded'), $q->end_html; }

Answer: I need a script for web file uploading.
contributed by QandAEditors

You can find some good scripts for this (most of which are free) at

Please (register and) log in if you wish to add an answer

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [marioroy]: Lady_Aleena Angels on earth are real people. That's awesome.
    [Lady_Aleena]: marioroy, what does MCE stand for in this instance? There are 3 pages of abbreviations to go through.
    [Lady_Aleena]: ^ or Discipulus...
    [marioroy]: Many-core Engine
    [choroba]: MCE
    [karlgoethebier]: is about to reach nirvana tonight...
    [Lady_Aleena]: It could have meant a "Miserably Cute Event" or "Man Crush Everyday". 8)
    [Corion]: choroba: Re the one-shot thing, I also thought of bit vectors and/or indexes into one common array from the hashes, but that makes maintenance of all these indices a chorse
    [Corion]: *core
    [Corion]: ** chore

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (12)
    As of 2017-05-29 08:28 GMT
    Find Nodes?
      Voting Booth?