J
J
John Freeman2016-02-11 02:38:01
PHP
John Freeman, 2016-02-11 02:38:01

How to upload an exe file?

There is a code:

$file_d = '/download/tmp_file/'.$rand_name.'/qwerty.exe';
$file_n = 'qwerty.exe';
    if (ob_get_level()) {
      ob_end_clean();
    }
    // заставляем браузер показать окно сохранения файла
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file_n));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file_d));
    // читаем файл и отправляем его пользователю
    readfile($file_d);
    exit;

The file gives but it is not working + also the chrome error says:
UWIMxCC.jpg
if I give it simply:
header( 'Refresh: 0; url=/download/tmp_file/'.$rand_name.'/qwerty.exe' );

then everything is fine!
How can I correctly give the file so that there are no warnings from chrome and that the signature does not fly off?
PS: I give away on a separate page! (Now if you do a header through a redirect, then when clicked, it redirects to the down.php page, when I click on DOWNLOAD, another window with information opens, I need something to work without a redirect)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Karl Meinhoff, 2016-02-11
@KarleKremen

<?
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename: myfile.exe");
$fl = file_get_contents("myfile.exe");
echo $fl;
?>

This code will work fine. Just put a link to this file on the "Download" button

K
Kostya00723, 2016-02-19
@Kostya00723

Why would you bother? Html 5 help
Google download tag

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question