Uploading and viewing photos

asp.net , db Viet Nam
  • 12 years ago

    Hi,
    I made a project where i can upload and view photos. If i try here there's no problem, but if im not in my computer i cant see the photos but i can upload them.

    1. My project it's in my drive C:\inetpub\
    2. My photo folder its in my drive F:\Photos

    Is this a security issue ? But if i can upload them , why cant i see them as well ?

    Ricardo Costa 

  • 12 years ago

    Hi Ricardo,

    Are you sure the URLs are correct in your ASP.NET page? What error do you get when you try to view the photo directly in the browser? 404 file not found, or some sort of server error?

    If you can upload them, then I imagine the file permissions have been set correctly - but it's worth checking that IUSR_machineName and NetworkService (or whatever identity ASP.NET runs under on your server) has read/write permissisons to that directory.

  • 12 years ago

    hi Ricardo,

    Just try this:

    - Create a folder in your application which will store the image.

     // Here there can be two cases:  1) you are saving the image in the folder. 2) your are saving the image in a database in binary format.

    if you are saving the image in the folder, and if you are saving the path of the same in the database then I hope you shouldn't have any problem.

    In your case I would suggest you to try to create a folder in your application and then try to upload image in that folder.

    String path = Server.MapPath("~/UploadedImages/");

    String fileExtension = System.IO.Path.GetExtension(fupldPhoto.FileName).ToLower(); 

    imgEmpPhoto.ImageUrl = "~/UploadedImages/" + txtEmpCd.Text.Trim() + "_Image" + fileExtension;

    In this code UploadedImages is the folder I have created in the application. fupldPhoto is the user control name to upload file. imageEmpPhoto is the Image User control name. txtEmpCd is the employee code whose images is being uploaded.

    Regards,

    Royal

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Owning a computer without programming is like having a kitchen and using only the microwave oven” - Charles Petzold