Forum Moderators: coopster
Let us know if you need a more detailed explanation. Google shows some nice examples if you search for 'php mail attachment', so maybe you don't even need WebmasterWorld...
but I'm wondering since I already opened the file and processed it line by line if I can (or should) "open" it again and then send it out, if there's a less processor intensive method of handling this so I won't need to process the file twice?
1a. read the uploaded file line by line and do your parsing
1b. at the same time, concatenate a string containing all the data
2. it should be safe to close the file now
3. compress the datastring, with gzencode()
4. base64-encode the compressed datastring, et cetera
AFAIK this could work...
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
and in my code I'm using
while ($datafieldvalues = fgetcsv ($fp, 10000, "$separator")) {
which puts the whole thing into an array...so I'm not quite sure how to put that into another variable?
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
OK... replace all that with
$data = implode($separator . "\n", $datafieldvalues); That should create a string of lines with your separator and a new line character at the end of the line.
Small print: Please note I haven't tested any of this... let's hope some guru steps in if I'm erring away...