Well, I'm still working on an email attachment prog through the
browser. The programs work, uploading and sending the email but the
graphic files cannot be viewed when received. The error msg reads
that the file type is unknown. During the upload process the graphic
file gif/jpeg can be viewed which is uploaded in binmode. The
graphic file is then attached with base64 encoding.
I'm uploading to a Unix server and receiving the attachment on a Mac.
Any thoughts on this problem would be much appreciated.
#UPLOAD
sub Upload {
my($query, $upload_dir) = @_;
my($file_query, $file_name, $size, $buff, $time, $bytes_count);
$size = $bytes_count =0;
$_ = $file_query = $query->param('file');
s/\w://;
s/([^\/\\]+)$//;
$_ = $1;
s/\.\.+//g;
s/\s+//g;
$file_name = $_;
if (! $file_name) {
$_ = $NAME_TITLE{'EU_BadFN'};
s/Value_FileName/$file_name/ig;
&Error($_, 1);
}
if (-e "$upload_dir/$file_name") {
$_ = $NAME_TITLE{'EU_FExist'};
s/Value_FileName/$file_name/ig;
&Error($_, 1);
}
open(FILE,">$upload_dir/$file_name") || &Error("Error opening
file $file_name for writing, error $!", 1);
binmode FILE;
$time=time();
while ($bytes_count = read($file_query,$buff,2096)) {
$size += $bytes_count;
print FILE $buff;
}
close(FILE);
if ((stat "$upload_dir/$file_name")[7] <= 0) {
unlink("$upload_dir/$file_name");
$_ = $NAME_TITLE{'EU_Size'};
s/Value_FileName/$file_name/ig;
&Error($_, 1);
} else {
$time = time -$time;
$_ = $NAME_TITLE{'Upload_Succes_txt'};
s/Value_FileName/$file_name/ig;
s/Value_Size/$size/ig;
s/Value_Time/$time/ig;
&ResutPage($NAME_TITLE{'Upload_Succes'}, $_);
}
}
#ENCODING
if ( $filename =~ /\.gif$/i )
{
$content_type = "image/gif; name=\"$filename\";
x-mac-type=\"47494666\"; x-mac-creator=\"4A565752\"";
$encoding = "base64";
}
elsif ( $filename =~ /\.jpg$/i )
{
$content_type = "image/jpeg; name=\"$filename\";
x-mac-type=\"4A504547\"; x-mac-creator=\"4A565752\"";
$encoding = "base64";
}
*** Teresa Raymond
*** http://www.mariposanet.com
*** [EMAIL PROTECTED]