Mumia, I don't think the problem is in sending the file out. When the file is recorded on /tmp/, its size is zero. The files I'm uploading are at least 1KB. Something's wrong with reading the file from the uploaded filehandle, I believe. Your example takes for granted a properly written file on disk, and doesn't include reading an uploaded file from a filehandle. I have other scripts that send out files as attachments using MIME::Lite, so I'm somewhat confident in this part of my script.
Thanks, though, for taking the time and effort to try to help me with my problems. -Kevin -----Original Message----- From: Mumia W. [mailto:[EMAIL PROTECTED] Sent: Thursday, February 22, 2007 9:59 PM To: Beginners List Subject: Re: File uploading using CGI On 02/22/2007 02:40 PM, Zembower, Kevin wrote: >> -----Original Message----- >> From: Mumia W. [mailto:[EMAIL PROTECTED] >> Sent: Thursday, February 22, 2007 3:27 PM >> To: Beginners List >> Subject: Re: File uploading using CGI >> >> On 02/22/2007 12:58 PM, Zembower, Kevin wrote: >>> I'm having problems uploading a file with perl and CGI.pm. I have a >> form >>> that uses a script with CGI and MIME::Lite to email the contents of >> the >>> form and the file uploaded to an individual. I've written this section >>> so far: >>> [...] >>> >>> $msg->attach(Type =>'BINARY', >>> Data =>$tmp_file_name, >>> Filename =>'AttachedFile', >>> Disposition =>'attachment'); >>> [...] >> >> "Data => $tmp_file_name" submits the temporary file's name as the data. >> You probably want to specify $tmp_file_name as the path to the file >> instead: >> >> Path => $tmp_file_name, >> >> Re-read the first few examples in "perldoc MIME::Lite" again. >> >> HTH >> > Mumia, thanks for your suggestion. Unfortunately, it didn't work; the > file in /tmp/ on the server is still empty and the attachment received > was only 64 bytes and was completely empty, as opposed to my previous > solution, which at least contained the file path and name. > > Thanks, again, for trying. > > -Kevin > MIME::Lite works here. Again, re-read the docs on MIME::Lite (perldoc MIME::Lite). I read the example, and that helped me create this example: #!/usr/bin/perl use strict; use warnings; use MIME::Lite; use File::Slurp qw(write_file); my $tmp_file_name = '/tmp/my-temp-file.txt'; my $from = "[EMAIL PROTECTED]"; my $to = $from; write_file $tmp_file_name, q{ This is a sample text file. It should be sent by mail using MIME::Lite. }; my $mime = MIME::Lite->new ( Type => 'multipart/mixed', From => $from, To => $to, Subject => 'Sample text file attached', ); $mime->attach( Type => 'text/plain', Data => 'Another text message should follow (or be attached).', ); $mime->attach( Type => 'text/plain', Path => $tmp_file_name, Filename => 'lite.txt', Disposition => 'attachment', ); print $mime->as_string; $mime->send; __END__ The only way it could be easier is if you could use the MIND::Reader module ;-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/