This is the form.
**<form action="" id="tform">
<input type="file" id="ff" name="nm" value="ss">
<button type="submit" class="btn btn-success">Button</button>
</form>**
This is ajax code.
**<script>
$("#tform").submit(function(e) {
e.preventDefault();
let a = $("#ff").val();
alert(a);
$.ajax({
url: "ajax.php",
type: "POST",
data:$("#tform").serialize(),
beforeSend: function() {
console.log("sending..");
},
success: function(response) {
alert(response);
},
});
});
**
This is php code.
**<?php
$pic = $_POST["nm"];
echo $pic;**
It always says Undefined array key "nm" but If change the type of it to text instead file it received that. File type did not get. Please help me I have been stuck here for 2 days.