Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
How to upload image to local host server in asp.net and then display on the webpage.
Posted
Comments
Zoltán Zörgő 13-Sep-12 8:55am    
And where do you intend to store the images: on the filesystem or in a database?
ZurdoDev 13-Sep-12 9:07am    
Just use an upload control and then save it to the server and create an img with the src set to the image. What have you done so far?

Hi,

You can use FileUpload control to upload your file and then you can Save that file in the server. (See this[^])

If you want to store your file in database then you can store it in varbinary field.(See this[^])

Hope this is what you want to know.
 
Share this answer
 
XML
<div>
       picture
       <asp:FileUpload ID="Fud_Pic" runat="server" onchange="PreviewImg(this)" />
       &nbsp;

     <br />
   <br />
   <br />
    <asp:Label ID="Label2" runat="server"></asp:Label>
   </div>



   <div id="newPreview">
       </div>

<asp button......="">

.cs_page
under the button click write this

XML
if (Fud_Pic.HasFile)
       {

           Label1.Text = "filelength:" + Fud_Pic.FileBytes.Length
               + "<br />"
               + "filename:"
               + Fud_Pic.FileName
               + "<br />"
               + "mimetype:"
               + Fud_Pic.PostedFile.ContentType;

           Fud_Pic.SaveAs(MapPath("~/images/")
               + Fud_Pic.FileName);

       }

       else
       {
           Label1.Text = "no files";
       }






it works fine...........

if u need a popupimage use this javascript


XML
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        #newPreview
        {
            filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);
        }
    </style>


    <script language="javascript" type="text/javascript">
    function PreviewImg(imgFile)
    {
        var newPreview = document.getElementById("newPreview");
        newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
        newPreview.style.width = "80px";
        newPreview.style.height = "60px";
    }
    </script>


</head>
 
Share this answer
 
v2

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