0

I want to save an image into a file and also retrieve that image as my application requirement.

I have a project in ASP.NET MVC. I am using G-light Box for better view of the image but I want to implement dynamic image functionality like,

How can I save an image in the Image folder and also retrieve from image from this image file?

Please check the following code.

   if (submit == "submit")
        {
            string[] Names = Imagefile.FileName.Split('.');
            String NewfileName = 2 + "." + Names[1];
            string RootFolder =Server.MapPath("~//Image//");
           List<cCreateFolder> collCreateFolder = new List<cCreateFolder>();
            collCreateFolder.Add(new cCreateFolder(Denver.DenLibrary.cUtil.ToString(1)));
            cCreateFolder createFolder = new cCreateFolder();
            string fullPath = createFolder.getFolderPath(collCreateFolder, RootFolder);
            Request.Files[0].SaveAs(fullPath + NewfileName);
            Homemodel.FileExtn = NewfileName;

}

<img src="~/Image/9739801B-930A-4AD8-B8D0-50B1EDA771F7-1.jpg" />
Mr Mush
  • 1,538
  • 3
  • 25
  • 38
acasdfsdfgh
  • 41
  • 1
  • 11
  • In above code, i`m able to save image but i am not getting in view side this image after save in image-folder. – acasdfsdfgh Oct 13 '15 at 07:07
  • Related advice on where/how to store files: http://stackoverflow.com/a/4535684/224370 – Ian Mercer Oct 13 '15 at 07:09
  • my dear friend, i need suggestion what is wrong with my code. – acasdfsdfgh Oct 13 '15 at 07:13
  • Your C# code shows `NewfileName` starting with `2.`, but your output doesn't - surely that tells you something? – Luke Oct 13 '15 at 08:35
  • i`m not getting your point. do you have any specific idea. – acasdfsdfgh Oct 13 '15 at 09:25
  • 1) Look on disk to see if the file is where you expect it to be; 2) Simplify the problem - we have no idea what `cCreateFolder` does. 3) Use a debugger to step through your saving code to see what happens – Ian Mercer Oct 13 '15 at 16:05
  • ok i got it. but my problem is i am not getting file in html even-if i am retrieving it from same directory where i saved the file. – acasdfsdfgh Oct 14 '15 at 06:53

0 Answers0