Click here to Skip to main content
15,920,602 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
If e.CommandName = "Down" Then

    Dim row As GridViewRow = DirectCast(DirectCast(e.CommandSource, LinkButton).NamingContainer, GridViewRow)
    Dim lblDoc = TryCast(row.FindControl("lbllog"), Label).Text
    Dim cs = "http://172.16.16.21/"
    Dim save = lblDoc.Substring(37)
    Dim savepath = "D:/Documents/"
    If (Not System.IO.Directory.Exists(savepath)) Then
        System.IO.Directory.CreateDirectory(savepath)
    End If

    Dim savetolocalsave = savepath + save
    Dim lblDoca = cs + lblDoc.Substring(16)





    'Dim webClient As New System.Net.WebClient()
    'webClient.DownloadFile(lblDoca, savetolocalsave)


What I have tried:

it saves image by url..but it saves the image from which server it comes..
not save on my local pc..i want to save image on my local pc..
Posted
Updated 12-Apr-17 1:29am
Comments
Jochen Arndt 12-Apr-17 7:03am    
You have to execute the code on your local PC.
Member 12300036 12-Apr-17 7:05am    
actually i create a webpage from where anyuser save that image on pc...how can i do that
Jochen Arndt 12-Apr-17 7:16am    
With HTML 5 you can use a <a href> tag with the download attribute.

With Asp.NET you can provide a button that creates a response with a "Content-Disposition: attachment" header. Otherwise the image would be displayed by the browser.

In all cases there will be a message box shown by the browser to specify which action should be taken.

Alternatively provide the image URLs as links so that the user can use the context menu to download them.
Member 12300036 12-Apr-17 7:49am    
how can i create responce and where i have to write that....
actually i did what u suggest but image is shown by click on that hyperlink
Jochen Arndt 12-Apr-17 7:56am    
Just Google for "asp.net download image as file":
http://stackoverflow.com/questions/16739598/asp-net-downloadable-image-files

Or use (HTML5, requires recent browser versions):
<a href="server-local-path-to-image/image-name.ext" download="file-name">

1 solution

You can't save files to the local machine from a web server. If web sites could save files on your local PC the security implications would be huge. It doesn't matter how many times you ask this question the answer is always going to be the same.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900