In asp .net you can try this type
protected void Submit(object sender, EventArgs e)
{
if (Path.GetExtension(FileUpload1.FileName) == ".jpg")
{
FileUpload1.SaveAs("path of where you save picture");
}
else
{
Response.Write("<script>alert('Invalid format')</script>");
}
}
For any query hit reply..