Programming Tips - jQuery: get upload filename

Date: 2022dec21 Language: javaScript Q. jQuery: get upload filename A.
<input id=myupload type=file>
$('#myupload').click(function() { const fileInputJq = $(this); const name1 = fileInputJq.val(); const fileInput = fileInputJq[0]; const fileObj = fileInput.files[0]; const name2 = fileObj.name; console.log('name1=' + name1 + ' name2=' + name2); // Outputs: // name1=C:\fakepath\myimage.jpg name2=myimage.jpg });
Tested on Firefox and Chrome