Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How to upload a file to a web server?

by bradcathey (Prior)
on Apr 07, 2005 at 08:49 UTC ( [id://445580]=note: print w/replies, xml ) Need Help??


in reply to How to upload a file to a web server?

The following uses the upload() function in CGI.pm >= 2.47.

HTML:

<form action="cgi-bin/uploader.pl" method="post" enctype="multipart/fo +rm-data">

Perl:

my $image = upload_file( "file_to_upload.txt", "../incoming" ); sub upload_file { local $| = 1; my( $filename, $path ) = @_; my $file = $query->upload($filename); # the magic open OUTPUT, "> $path/$filename" or die "$path/$filename - $!"; binmode $file; binmode OUTPUT; my $buffer; while ( read( $file, $buffer, 64*2**10 ) ) { print OUTPUT $buffer; } close OUTPUT; close $file; return( $filename ); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://445580]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-26 05:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found