Click here to Skip to main content
15,936,897 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
i want to store image in image folder not in database,how can i do this.please give complete code that can i understand
Posted
Updated 13-Feb-17 2:08am
Comments
RDBurmon 13-Jun-12 9:30am    
Thanks Everyone who replied to this thread , So Manohar, I think you have got enough responses and you should be able to mark it as your answer and close the thread. Please do so.

XML
<asp:FileUpload ID="fupload" runat="server" Height="21px" Width="220px" />

Add One Asp Button try this below code in that button click
C#
string strFileName = DateTime.Now.ToString("MM-dd-yyyy_HHmmss");
string strFileType = System.IO.Path.GetExtension(fupload.FileName).ToString().ToLower();
fupload.SaveAs(Server.MapPath("folderpath" + strFileName + strFileType));
 
Share this answer
 
v2
 
Share this answer
 
Try:
C#
myImage.Save(path, ImageFormat.Jpeg);
 
Share this answer
 
.........It may work
C#
if (imgUpload.HasFile)
        {
            //Check File is available in Fileupload control and then upload to server path
            fname = imgUpload.FileName;
            //spath = @"~\ImgUpload\" + FileUpload.FileName;
            fpath = Server.MapPath("ImgUpload");
            fpath = fpath + @"\" + imgUpload.FileName;
            string getext = Path.GetExtension(imgUpload.PostedFile.FileName);
            string filename = Path.GetFileNameWithoutExtension(imgUpload.PostedFile.FileName);
            string strFilePath = filename + DateTime.Now.ToString("yyyyMMdd") + getext;
            if (getext != ".JPEG" && getext != ".jpeg" && getext != ".JPG" && getext != ".jpg" && getext != ".png" && getext != ".tif" && getext != ".tiff")
            {
                Page.ClientScript.RegisterStartupScript(typeof(Page), "successfull", "alert('Please upload only jpeg, jpg,png,tif,tiff'); window.location = 'ParivarRegistration.aspx';", true);
            }
            else
            {
                imgUpload.SaveAs(Server.MapPath(@"~\ImgUpload\" + strFilePath));
                ImageShow.ImageUrl = @"~\ImgUpload\" + strFilePath;
                ViewState["fname"] = fname;
                ViewState["fPath"] = @"~\ImgUpload\" + strFilePath;
            }
        }
        else
        {
             lblMessage.Text = "Please select file!";
             
        }
 
Share this answer
 
v2
string path = @"~/imgage/";
string picture = "your picture name with extention";
                                path = Path.Combine(Server.MapPath(path), picture);
                                using (WebClient wc = new WebClient())
                                {
wc.DownloadFile("http://www.example.com/image/abc.jpg", path);
                                }
 
Share this answer
 
Comments
[no name] 13-Feb-17 12:54pm    
Why are you answering already answered FIVE year old questions?

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