all groups > asp.net webcontrols > february 2008 >
You're in the

asp.net webcontrols

group:

storing images in filesystem


storing images in filesystem nbs6@yahoo.com
2/15/2008 6:00:07 PM
asp.net webcontrols:
I am convinced that I want to store images in filesystem as to
database and store path into database Can someone point out an
article as to how to do it or help me I am using fileupload method but
Re: storing images in filesystem Nathan Sokalski
2/17/2008 4:36:05 PM
I'm not sure where the best article would be found, but I'm sure you could
find plenty with a search. But here is a basic example that should get you
started:

If fileupload1.HasFile AndAlso fileupload1.FileContent.Length > 0 Then
If Not System.IO.File.Exists(Server.MapPath(String.Concat("/",
fileupload1.FileName))) Then
Me.fileupload1.PostedFile.SaveAs(Server.MapPath(String.Concat("/",
fileupload1.FileName)))
End If
End If

The first If statement checks to make sure a file has been selected and that
the file actually has content. The second If statement checks to make sure
that there is not already a file in the directory with that name. If both of
these If statements pass, then the SaveAs method of the PostedFile property
of the FileUpload control is called. Take note that you do not have to use
the filename of the original file, although whether or not you do depends on
the intended usage of you application. Also, take note of the Server.MapPath
function that I used. This is important, because you must specify the path
on the server. Hopefully this will get you started; if you have any
questions that you cannot find answers to, feel free to ask.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

[quoted text, click to view]

AddThis Social Bookmark Button