If I have this code on my page then it works
index.html
<input type="file" name="data[Post][picture]" hidden="1" onchange="uploadPhoto(this.files)" id="PostPicture"/>
script.js
function uploadPhoto(files){
//TODO
console.log(files);
}
but that code requires me to put uploadPhoto() function out of jquery $() function. I have certain problems with variable scope and so I don't want to get my function outside of document.ready function.
for that I did something like this
$(function(){
var uploadPhoto = function(){
//TODO
console.log($('#PostPicture').files);
};
$('#PostPicture').on('change',uploadPhoto);
});
and it logs undefined in the console.