Saving Images

Discussion in 'ASP.NET / ASP.NET Core' started by aaron, Jun 18, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Okay, so here is what I am trying to do. I hope this makes sense.

    I have an application where the user will browse to an image. I need to then upload the image to the server. I am using SQL, but I don't want to save the image there, I just want the path to the image saved there so that when I need to retrieve the image I just get that path from SQL. I got a browse button working so that I can browse to an image, but from there I don't know what I need to do to save it to the serve as well as save the path in SQL. Can someone point me to an example or how I can do this.

    Thank you

    Aaron
     
  2. Hi Aaron,

    It makes sense and it's a common thing to do. For simple cases I would recommend just using the .NET 2.0 <asp:FileUpload/> control. If you haven't used it before there is a good article that will get you started here: http://msdn.microsoft.com/en-us/library/aa479405.aspx. Once a file is uploaded you can save it to the server's file system just like the example code, although you would obviously use Server.MapPath instead of a hard coded path. You would also be able to store the path to your saved file into you db as you need to.

    For more complex cases there are web based file managers available and one I can recommend is http://www.ckfinder.com/. It's not free (it is cheap at $59 for a single site) but it has a powerful UI for the user including file thumbnails and as a developer you can also do some nifty stuff server side to enable segmented per-user upload areas.

    I suppose there are other options if you need to do multiple asynchronous uploads with AJAX. If this is the case then you might want to have a look at this one http://www.asp.net/community/control-gallery/Item.aspx?i=2565 and the Telerik web controls are also very good, but they are not cheap.

    Cheers,
    Joe
     
  3. Thank you for the info. I will go and check it it right away.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page