Deepak Ratan

Deepak Ratan

  • NA
  • 175
  • 50.8k

Getting Error in fileupload

May 18 2015 8:07 AM
protected void signout_Click(object sender, EventArgs e)
{
      string photo;
      string path;
      if (Fileuploadprofilepick.PostedFile.ContentLength > 0)
      {
            photo = path.GetFileName(Fileuploadprofilepick.FileName);
            path = Server.MapPath("images") + "/" + photo;
            Fileuploadprofilepick.SaveAs(path);
      }
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString);
      string query = "INSERT INTO TBL_PBLogin (UName,Password,photo) VALUES (@UName,@Password,@photo)";
      try
      {
         con.Open();
         SqlCommand cmd = new SqlCommand(query, con);
         cmd.Parameters.Add("@UName", txtUname.Text);
         cmd.Parameters.Add("@Password", txtUpassword.Text);
         cmd.Parameters.Add("@photo",photo);
         cmd.CommandType = CommandType.Text;
         cmd.ExecuteNonQuery();
         con.Close();
         ClearControl();
      }
catch (Exception ex)
{
   throw new Exception(ex.ToString());
}
}
 
 
ERROR:
Error 3 'string' does not contain a definition for 'GetFileName' and no extension method 'GetFileName' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) 
 

Answers (8)