file upload
protected void btnsave_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile == false)
{
lblpicname.Text = "Please select a file";
}
else
{
FileUpload1.SaveAs(Server. MapPath("~") + "//profiles//" + FileUpload1.FileName);
lblpicname.Text = FileUpload1.FileName;
if (FileUpload1.HasFile)
{
string extension = System.IO.Path.GetExtension( FileUpload1.FileName);
if (extension == ".jpg" || extension == ".jpeg" || extension == ".png" || extension == ".JPG" || extension == ".JPEG" || extension == ".PNG" || extension == ".BMP")
{
FileUpload1.SaveAs(Server. MapPath("~") + "//profiles//" + FileUpload1.FileName);
lblpicname.Text = FileUpload1.FileName;
update();
show();
}
else
{
ScriptManager. RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('Only .jpg,jpeg,png,bmp File allowed')", true);
}
}
}
}
{
if (FileUpload1.HasFile == false)
{
lblpicname.Text = "Please select a file";
}
else
{
FileUpload1.SaveAs(Server.
lblpicname.Text = FileUpload1.FileName;
if (FileUpload1.HasFile)
{
string extension = System.IO.Path.GetExtension(
if (extension == ".jpg" || extension == ".jpeg" || extension == ".png" || extension == ".JPG" || extension == ".JPEG" || extension == ".PNG" || extension == ".BMP")
{
FileUpload1.SaveAs(Server.
lblpicname.Text = FileUpload1.FileName;
update();
show();
}
else
{
ScriptManager.
}
}
}
}