I want to download a *.exe file from a php script and execute it.
After I download the file I can' execute it anymore. When I look inside the file there are a lot question marks in it.
PHP script:
header('Content-Description: File Transfer');
header('Content-Type: application/x-download');
header('Content-Disposition: attachment; filename='.basename($file_name));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file_name));
ob_clean();
flush();
readfile($file_name);
exit;
C++:
QFile offline_ip_adress_calculator(QDir::currentPath() + "/offline_ip_adress_calculator.exe");
//Check if the File exists and clear its content
if(!offline_ip_adress_calculator.open(QFile::ReadWrite | QIODevice::Truncate))
{
msgBox.critical(this, "I/O error", "Can't open offline_ip_adress_calculator.exe for update");
return;
}
QDataStream text_stream(&offline_ip_adress_calculator);
while(reply->size() > 0)
{
QByteArray replystring = reply->read(2048);
text_stream << replystring;
}
offline_ip_adress_calculator.close();
reply is a "QNetworkReply"