|
Posted by Rik on 01/13/07 15:19
Manfred Kooistra wrote:
> Thank you, Rik.
> Alas, that wasn't it.
>
> I found out that the problem was trying to attach the file after
> fopening and freading it. On debug, I got an error message telling me:
> "File is not readable." I was wondering about that, because that files
> permissions and path are alright. So I simply attached it without
> fopening it - and that did the trick!
>
> Not working:
>
> $handle = fopen($uploaded_file_path, 'r');
> $file = fread($handle, filesize($uploaded_file_path));
> $mime->addAttachment($file, "image/$typ", $uploaded_file_name);
> fclose($handle);
>
> Working:
>
> $mime->addAttachment($uploaded_file_path, "image/$typ",
> $uploaded_file_name);
>
> (with $typ preg_match/substr-ed from the file name)
>
> I wonder about this, because I found hundreds of
> mail-attachment-examples with fopen/fread, but I'm happy that my
> script is running and I get mailed the uploaded files.
Well, it always pays to read up on the functions. Does it take the data of
a file, or the filename, that's the only difference.
--
Rik Wasmus
Navigation:
[Reply to this message]
|