Click here to Skip to main content
15,947,389 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi friends,
C#
string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
                string path = Server.MapPath("~//Images//" + FileName);
                FileUpload1.SaveAs(path);
                string imagepathsource = path;
                string imagepathdest = @"D:\\" + Session["brandname"].ToString() + "\\" + Seasonfolders.SelectedItem.Text + "\\" + stylefolders.SelectedItem.Text + "\\Images\\" + FileName;
                File.Move(imagepathsource, imagepathdest);
                uploadedimage.ImageUrl = MapPath("D://" + Session["brandname"].ToString() + "//" + Seasonfolders.SelectedItem.Text + "//" + stylefolders.SelectedItem.Text + "//Images//" + FileName);

Just a small doubt.

By the above code, I just upload an image. My program(.sln) file is in E:\\Folder1\\Folder2 and I save the image in above directory and moved that file to my destination folder. The file successfully moved. I need to display the uploaded image using Image.url which I've specified using the folder. But the error throws as Expected Virtual path not physical path.
How do I show the path, in the directory used below..

Thanks in advance
Posted

 
Share this answer
 
Comments
Sriram Ramachandran 15-May-14 6:06am    
Thanks Nilesh..I got the problem solved but the image has not been displayed. The image path is right when debugging but nothing displays.... Do I need to add any code??
Sriram Ramachandran 15-May-14 6:11am    
I could see the page is getting refreshed when I hit the Upload button. The function for the button is the above code...
You ll have to load the image as a byte stream

for example: the VB code i use:-

VB
Dim FileName As String = Path.GetFileName(FileUpload1.PostedFile.FileName)


Dim imageSize As Byte() = New Byte(FileUpload1.PostedFile.ContentLength - 1) {}
Dim uploadedImage__1 As HttpPostedFile = FileUpload1.PostedFile

uploadedImage__1.InputStream.Read(imageSize, 0, CInt(FileUpload1.PostedFile.ContentLength))

Image1.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(imageSize)
 
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