upload image working in localhost , but on server not

Sep 10 2020 2:07 AM
I have a site with upload image, on localhost working, but when I deploy it to server not working give me this error
 
Error! Object reference not set to an instance of an object
 
this is the method,
  1. public string Createcontant(string articalname, string KEYWORD_NAME, string articalbody , HttpPostedFileBase file)  
  2. {  
  3. Contant c1 = new Contant() ;  
  4. OracleConnection conn = new OracleConnection();  
  5. OracleCommand cmd = new OracleCommand();  
  6. int MaxContentLength = 1024 * 1024 * 3; //3 MB  
  7. string[] AllowedFileExtensions = new string[] { ".jpg"".gif"".png"".pdf" };  
  8. var fileName = Path.GetFileName(file.FileName);  
  9. var path = Path.Combine(HttpContext.Current.Server.MapPath("~/Images"), fileName);  
  10. file.SaveAs(path);  
  11. try  
  12. {  
  13. conn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;  
  14. cmd.Connection = conn;  
  15. conn.Open();  
  16. cmd.Parameters.AddWithValue("photo", fileName);  
  17. cmd.Parameters.AddWithValue("articalname", articalname);  
  18. cmd.Parameters.AddWithValue("KEYWORD_NAME", KEYWORD_NAME);  
  19. cmd.Parameters.AddWithValue("articalbody", articalbody);  
  20. cmd.Parameters.AddWithValue("parAddedUser", HttpContext.Current.Session["UserName"].ToString());  
  21. cmd.Parameters.AddWithValue("articalbody", articalbody);  
  22. string sql = "insert into contact" +  
  23. "( ARTICL_ID, ARTICAL_NAME, IDATE, IUSER," +  
  24. " KEYWORD_NAME, ARTICALBODY ,photo )" +  
  25. " Values " +  
  26. "( CONTANT_SEQ.nextval, :articalname,sysdate,:parAddedUser," +  
  27. " :KEYWORD_NAME,:articalbody , :photo)";  
  28. cmd.CommandText = sql;  
  29. cmd.ExecuteNonQuery();  
  30. cmd.Dispose();  
  31. cmd.Parameters.Clear();  
  32. return "done";  
  33. }  
where is the problem?

Answers (2)