Downloading

Hi,

What is the best way of downloading a file when a button is clicked?

Thanks,

Ken

You can use:


asm
 window.location.href = AURL;
end;

In the next update, we'll expose this as a helper function at TApplication level to make this possible in 100% Pascal code with:

Application.Download(URL);
Thanks Bruno but if I put this assembler code in my application in an OnClick event I get a blank screen when running it locally. If I remove it it is fine.

Should I only be calling this once the html is deployed to a server?

Regards,

Ken

Does the URL references a local file? What file type is it?

When the MIME settings of the local server do not permit this file is downloaded, it indeed won't work.



No it is a full URL.

I retested this with a ZIP file absolute URL on our own web server, and this worked and showed the browser download dialog upon starting.

Is there anything wrong with the following?

asm
  wind ow.location.href='http://www.simplyaccounts.net/Downloads/Setup.exe';
end;

I tested this 


procedure TForm2.WebButton1Click(Sender: TObject);
begin

 asm
 end;
end;

and it starts the download here in the Chrome browser.

Thanks Bruno, Working now.Not used to using asm.