Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

I need a script for web file uploading.

( #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 read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (5)
    As of 2014-12-29 01:07 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (183 votes), past polls