Osram Posted April 8, 2020 Share Posted April 8, 2020 I have made a Php program that downloads an Inno setup installation file for installing a program. However, if I for one or another reason want to make a new download of the same Inno setup installation file, the previous file will still be found in the Download folder. Each of the downloads get a number in parenthesis, setup(1), setup(2), setup(3) etc. However, I wondered if it is posible to erase the previous file in the same process as I download a new one, so that however many downloads I do, there will all the time only be one occurence of this file in the Download folder. The download code is as follows: $exe = "Inno script/Test_setup.exe"; header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"Test_setup.exe\""); header("Content-Length: " . filesize($exe)); readfile($exe); Thanks in advance. Sincerely Quote Link to comment https://forums.phpfreaks.com/topic/310504-how-to-replace-a-download-with-a-new-download/ Share on other sites More sharing options...
requinix Posted April 8, 2020 Share Posted April 8, 2020 You cannot overwrite or delete a file from the client's computer. The user has to tell their browser that they want to overwrite, and that means a Save dialog. 1 Quote Link to comment https://forums.phpfreaks.com/topic/310504-how-to-replace-a-download-with-a-new-download/#findComment-1576564 Share on other sites More sharing options...
Osram Posted April 8, 2020 Author Share Posted April 8, 2020 (edited) So how should one then intiate and make this dialog? Edited April 8, 2020 by Osram Quote Link to comment https://forums.phpfreaks.com/topic/310504-how-to-replace-a-download-with-a-new-download/#findComment-1576566 Share on other sites More sharing options...
requinix Posted April 8, 2020 Share Posted April 8, 2020 PHP can recommend a Save dialog by using Content-Disposition: attachment. Which you're already doing. Otherwise it's up to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/310504-how-to-replace-a-download-with-a-new-download/#findComment-1576567 Share on other sites More sharing options...
Osram Posted April 8, 2020 Author Share Posted April 8, 2020 Sorry, I don't quite understand what you mean. Is there something I can add to the Content-Disposition line? Quote Link to comment https://forums.phpfreaks.com/topic/310504-how-to-replace-a-download-with-a-new-download/#findComment-1576568 Share on other sites More sharing options...
requinix Posted April 8, 2020 Share Posted April 8, 2020 No. Quote Link to comment https://forums.phpfreaks.com/topic/310504-how-to-replace-a-download-with-a-new-download/#findComment-1576569 Share on other sites More sharing options...
Osram Posted April 9, 2020 Author Share Posted April 9, 2020 Ok. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/310504-how-to-replace-a-download-with-a-new-download/#findComment-1576583 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.