PDA

View Full Version : Problems Encoding to Base64



racinglocura07
17th June 2010, 19:46
I am having problems encoding a file to base64.

I want to send a pdf by mail so i have to encode it to base64

When i do this:


QString data;
QFile file(filename);
file.open(QIODevice::ReadOnly | QIODevice::Text);

while (!file.atEnd())
{
QByteArray line = file.readLine();
data += line.toBase64();
}


The string data seems to content all the information, but if i attached it into a mail i could not open the file

I hope you could help me

Sorry for my bad english

wysota
17th June 2010, 19:49
You have to encode the whole string at once, not line by line.

squidge
17th June 2010, 20:03
Secondly, is your MIME header correct?

racinglocura07
17th June 2010, 20:08
i have also tried readAll();

But the result was the same...

Yes the MIME is correct!

squidge
17th June 2010, 21:11
Then either post the complete code you use for generating the email, or post the generated email (as an attachment)

Toro
24th July 2010, 12:31
I encounter the same problem.
I need to fill the postfields with base64 encoded.


QFile sourceFile(filename);
QByteArray srcRawData = sourceFile.readAll();
QByteArray base64Encoded = srcRawData.toBase64();


But the web site doesn't recognize the base64 string.

wysota
24th July 2010, 15:17
What do you do with the encoded string?