storing images in filesystem

N

nbs6

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
I am getting nowhere
 
N

Nathan Sokalski

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top