We can store each file as binary large object in database.(BLOB).
We need to do in two steps.
Step 2 : QByteArray is stored as BLOB.
To retrieve :
QFile
file(fileName);
if
(!file.open(
QIODevice
::ReadOnly))
return
;
QByteArray
byteArray = file.readAll();
QSqlQuery
query;
query.prepare(
"INSERT INTO imgtable (imgdata) VALUES (?)"
);
query.addBindValue(byteArray);
query.exec();
QSqlQuery
query(
"SELECT imgdata FROM imgtable"
);
query.next();
QByteArray
array = query.value(0).toByteArray();
QSqlQuery
query(
"SELECT imgdata FROM imgtable"
);
query.next();
QByteArray
array = query.value(0).toByteArray();
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteCan u pls show how to display the stored file in widget and to save in a specific path
ReplyDeleteI need to store the PDF file into the database
ReplyDelete