(redirected from Main.MultiPartFormsAndFileUploading)
From: owner-monkeyjunkies@wired.com on behalf of Tamara Temple
Sent: Thursday, November 26, 1998 3:11 AM
To: monkeyjunkies@wired.com
Subject: RE: [mj] CGI.pm Multi-Part Forms, sendmail attachments
> 'Gotta' agree with Alan `McCoy's <objunky> regarding CGI.pm!
me too me too!
> I've got a form set up just fine, but i'd also like to allow the user
> to upload a file that would ideally be sent along as an attachment
> with the sendmail portion of the script i'm using on the page.
umm -- isn't this explained in the CGI.pm Pod? 'Creating a File Upload
Field' describes how to do this:
print $q->start_multipart_form(),
$q->filefield(-name='uploadfile',-size='50'),
$q->endform;
and you process the file. If you're expecting binary (or you don't know what
to expect), then process the file using binary reads:
$filename = $q->param('uploadfile');
open OUT '>/tmp/safe/place/to/store/files.bin';
while ($bytesrd=read($filename,$buffer,1024)) {
print OUT $buffer;
}
close OUT;
and now you can continue to futz with the file all you want.
Sent: Thursday, November 26, 1998 3:11 AM
To: monkeyjunkies@wired.com
Subject: RE: [mj] CGI.pm Multi-Part Forms, sendmail attachments
> 'Gotta' agree with Alan `McCoy's <objunky> regarding CGI.pm!
me too me too!
> I've got a form set up just fine, but i'd also like to allow the user
> to upload a file that would ideally be sent along as an attachment
> with the sendmail portion of the script i'm using on the page.
umm -- isn't this explained in the CGI.pm Pod? 'Creating a File Upload
Field' describes how to do this:
print $q->start_multipart_form(),
$q->filefield(-name='uploadfile',-size='50'),
$q->endform;
and you process the file. If you're expecting binary (or you don't know what
to expect), then process the file using binary reads:
$filename = $q->param('uploadfile');
open OUT '>/tmp/safe/place/to/store/files.bin';
while ($bytesrd=read($filename,$buffer,1024)) {
print OUT $buffer;
}
close OUT;
and now you can continue to futz with the file all you want.
| Tags: | Categories: HowTos |
Recent Changes |
Printable View |
Page History |
Edit Page
Page last modified on April 17, 2012, at 08:59 PM by ImportText?