function tryme() {
var modelx = new Object();
var myFilefile = $('#fileinput').prop('files'"files");[0];
$.ajax({
modelx type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
url: '@Url.fAction("CreateRequest", ="Home")',
myFile; data: "{'File':'" + file + "'}",
success: function (response) {
alert(modelx.f"at least Ajax looks fine");
},
Error: function (textMsg) {
alert("something got wrong");
}
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" id="fileinput" />
<input type="submit" onclick="tryme()" value="click" />
</body>
</html>
public JsonResult CreateRequest(FileInfo format )
{
string cs = "Data Source=DMX87025;Initial Catalog=DB_PCC;Integrated Security=True";
string sql = "INSERT INTO [DB_PCC].[dbo].[Testsoru]" +
"([Format])" +
"VALUES" +
"(@Format)";
using (SqlConnection con= new SqlConnection(cs) ) {
SqlCommand cmd = new SqlCommand(sql,con);
cmd.Parameters.Add("@Format", SqlDbType.VarChar).Value = format;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
return Json(new { success = true, message = "Success Baby Doll :* ;)"D" }, JsonRequestBehavior.AllowGet);
// End CreateRequest
}
function tryme(){
var modelx = new Object();
var myFile = $('#fileinput').prop('files');
modelx.f = myFile;
alert(modelx.f);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" id="fileinput" />
<input type="submit" onclick="tryme()" value="click" />
</body>
</html>
public JsonResult CreateRequest(FileInfo format )
{
string cs = "Data Source=DMX87025;Initial Catalog=DB_PCC;Integrated Security=True";
string sql = "INSERT INTO [DB_PCC].[dbo].[Testsoru]" +
"([Format])" +
"VALUES" +
"(@Format)";
using (SqlConnection con= new SqlConnection(cs) ) {
SqlCommand cmd = new SqlCommand(sql,con);
cmd.Parameters.Add("@Format", SqlDbType.VarChar).Value = format;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
return Json(new { success = true, message = "Success Baby Doll :* ;)" }, JsonRequestBehavior.AllowGet);
// End CreateRequest
}
function tryme() {
var file = $('#fileinput').prop("files")[0];
$.ajax({
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
url: '@Url.Action("CreateRequest", "Home")',
data: "{'File':'" + file + "'}",
success: function (response) {
alert("at least Ajax looks fine");
},
Error: function (textMsg) {
alert("something got wrong");
}
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" id="fileinput" />
<input type="submit" onclick="tryme()" value="click" />
</body>
</html>
public JsonResult CreateRequest(FileInfo format )
{
string cs = "Data Source=DMX87025;Initial Catalog=DB_PCC;Integrated Security=True";
string sql = "INSERT INTO [DB_PCC].[dbo].[Testsoru]" +
"([Format])" +
"VALUES" +
"(@Format)";
using (SqlConnection con= new SqlConnection(cs) ) {
SqlCommand cmd = new SqlCommand(sql,con);
cmd.Parameters.Add("@Format", SqlDbType.VarChar).Value = format;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
return Json(new { success = true, message = "Success:D" }, JsonRequestBehavior.AllowGet);
// End CreateRequest
}