The path of the image won't do you any good - it will be a local path on the user's computer, which your code running on the server won't be able to access.
What you need to do is read the content of the file which has been posted to the server.
Either add
runat="server"
to your file input and access the
PostedFile
property:
<input type='file' id="FileUploadImage" runat="server" />
protected void btnSave_Click(object sender, EventArgs e)
{
HttpPostedFile theFile = FileUploadImage.PostedFile;
...
}
or give the file input a
name
and use the
Request.Files
collection:
<input type='file' id="FileUploadImage" name="FileUploadImage" />
protected void btnSave_Click(object sender, EventArgs e)
{
HttpPostedFile theFile = Request.Files["FileUploadImage"];
...
}
Now you've got
an HttpPostedFile
instance[
^] representing the uploaded file, you can either
save it to disk[
^], or use
the InputStream
property[
^] to read the content of the file into a byte array, which you can then store in the database.
For example:
http://www.aspsnippets.com/Articles/Save-Files-to-SQL-Server-Database-using-FileUpload-Control.aspx[
^]