0

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.

2
  • do you get any error? try use "~/images/" + UploadPic.FileName Commented Feb 23, 2012 at 9:01
  • What is a class of UploadPic? Commented Feb 23, 2012 at 9:08

2 Answers 2

2

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...

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.