Enable user to upload file

I am working on an image gallery, and in the image viewer I have a download icon. I need it to work as a download button. When a user clicks on it, they should be presented with a file save dialog or the file should be uploaded using the default browser download settings.

I tried many ways, but no luck.

  • Download icons are displayed in the Modal pop-up window and, therefore, all code is wrapped inside the UpdatePannel

  • These images have different formats (jpeg, gif, tif, psd)

+4
source share
2 answers

Finally, sorted using:

A) To upload a file to a Client Location:

public void downloadFile(string fileName, string filePath) { Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", fileName)); Response.WriteFile(filePath + fileName); } 

B) Since the function launch controls ( imgDownload , imgDownloadPsd ) are wrapped under an asynchronous call: add this to the Download page:

 protected void Page_Load(object sender, EventArgs e) { ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(imgDownload); ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(imgDownloadPsd); } 
0
source

Source: https://habr.com/ru/post/1411756/


All Articles