Hi, Use this code to store an image in the online server.

Before doing that we must give Permisiions to the folder in which you want to store Images.

Give Read and Write Permissions.

You must use fileupload control to do this:

Here is the code:

string extn =    System.IO.Path.GetExtension(FileUpload1.FileName);

if ((extn == “.jpg”) || (extn == “.gif”) || (extn == “.png”) || (extn == “.jpeg”))
{
path = Server.MapPath(“~/Documents”) + “//” + FileUpload1.FileName;
FileUpload1.SaveAs(path);

string script = “alert(‘Document Uploaded Successfully…’);”;
Page.ClientScript.RegisterStartupScript(this.GetType(), “str”, script, true);

}
else
{
string script = “alert(‘Invalid File Format…’);”;
Page.ClientScript.RegisterStartupScript(this.GetType(), “str”, script, true);
}
Any doubts Mail Me at radhek@gmail.com

Advertisements