Jump to content
Osram

How to replace a download with a new download

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

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.

  • Great Answer 1

Share this post


Link to post
Share on other sites
Posted (edited)

So how should one then intiate and make this dialog?

 

 

Edited by Osram

Share this post


Link to post
Share on other sites

PHP can recommend a Save dialog by using Content-Disposition: attachment. Which you're already doing. Otherwise it's up to the browser.

Share this post


Link to post
Share on other sites

Sorry, I don't quite understand what you mean. Is there something I can add to the Content-Disposition line?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.