Reputation: 1126
I am currenlty stuck on a small project. Here is my code;
String StuPicc = Server.MapPath("images/" + UploadPic.FileName);
UploadPic.SaveAs(StuPicc);
UploadPic is the control name. But, neither it display the name nor upload the selected image. When i output the result on a label it display;
images/{image name isn't showing here}
Any help regard to this will be apreciatable.
Upvotes: 0
Views: 442
Reputation: 1895
If you are using a file upload control then..FileUploadControl ID="FuImage" file upload control..and uploaded files will be saved in "UploadedFiles" folder.
string path = "\\UploadedFiles\\" + Guid.NewGuid() + FuImage.FileName;
FuImage.SaveAs(Server.MapPath(".") + path);
Hope this helps...
Upvotes: 2
Reputation: 537
Are you using the FileUpload control? I believe the filename is available from the inputfile property then, although the only code I have used is to retrieve the stream:
System.Drawing.Image i =
System.Drawing.Image.FromStream(flUploader.PostedFile.InputStream);
flUploader.PostedFile.Filename
should be valid along with the input stream if the upload is occuring.
Upvotes: 1