On May 17, 1:04 pm, "Victor" <vic...@noemail.noemailwrote:
Hi.
Is there a good way to let user can download image as a normal file? Like
like the image then popup a messagebox ask user whether he want to save it
or open it?
Cheers
Victor
download.aspx:
public partial class download : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string filePath = Server.MapPath("~") + "\\test.jpg";
if (File.Exists(filePath))
{
Response.AddHeader("Content-Disposition", "attachment;
filename=test.jpg"); // make sure keep this
Response.TransmitFile(filePath);
}
else
{
Response.Write("No such file : " + filePath);
}
}
}
}
Default.aspx:
<a href="download.aspx?id=1">image link</a>
hope helpful
Spring