我想从 php 脚本下载 *.exe 文件并执行它。
下载文件后,我无法再执行它。当我查看文件时,里面有很多问号。
PHP 脚本:
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();
回复是“QNetworkReply”