CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Uploads images using cgi-lib.pl

 



djpaul
Deleted

Jul 20, 2000, 9:07 AM

Post #1 of 2 (850 views)
Uploads images using cgi-lib.pl Can't Post

Please help me, I need to be able to upload files using cgi-lib.pl. I have a script now, but when I upload images they come out all screwy. I tried putting the filehandle in binmode, nothing works.

Thanks ahead,
Paul


Jasmine
Administrator

Aug 6, 2000, 9:00 AM

Post #2 of 2 (850 views)
Re: Uploads images using cgi-lib.pl [In reply to] Can't Post

Actually, you may wish to toss cgi-lib.pl out the window and replace it with CGI.pm. cgi-lib.pl was popularly used with Perl4, but CGI.pm is the "de facto standard" for Perl5+. Using CGI.pm, you can use the following code to upload files:

For your form tag and file upload field:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


print start_multipart_form();
filefield(-name=>'upload',-size=>60),br,
submit(-label=>'Upload File'),
end_form;
</pre><HR></BLOCKQUOTE>

Then, to process the input:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$file = param->{'upload'};
open(SAVE,"filenametosave") &#0124; &#0124; die $!;
while(read($file,$data,1024)){
print SAVE $data;
}
close SAVE;
</pre><HR></BLOCKQUOTE>

In other words, I don't know how to use cgi-lib.pl, only CGI.pm. You may have a hard time finding someone who knows enough to help you with that dinosaur Smile

(The above code was excerpted from "Official Guide to Programming with CGI.pm" by Lincoln Stein. Publisher: Wiley Computer Publishing)

Footnote: if you're interested in converting your scripts from cgi-lib.pl to CGI.pm, check out Lincoln Stein's "Porting cgi-lib.pl Scripts to CGI.pm" article at http://stein.cshl.org/WWW/software/CGI/cgi-lib_porting.html

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives