html
<div id="file_img">
<input class="file" accept="image/*" name="titleFilePath" type="file"/>
</div>
js
$("#file_img").on("change", ".file", function (e) {
var _this=$(this);
var src=$(this).val();
var formData = new FormData();
formData.append("upload", _this[0].files[0]);
$.ajax({
type: 'post',
url:'',
data:formData,
processData: false,
contentType: false,
success:function(res){
var _res=JSON.parse(res);
console.log(_res.data);
_this.attr("data-url",_res.data);
}
});
});