upload.php
$(document).ready(function(){
$('#upload').on('click', function() {
var file_data = $('#pic').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
$.ajax({
url : 'upload.php', // point to server-side PHP script
dataType : 'text', // what to expect back from the PHP script, if anything
cache : false,
contentType : false,
processData : false,
data : form_data,
type : 'post',
success : function(output){
alert(output); // display response from the PHP script, if any
}
});
$('#pic').val(''); /* Clear the file container */
});
});
</script>
</head>
<body>
<input id="pic" type="file" name="pic" />
<button id="upload">Upload</button>
</body>
は、それが空を示しているように、最初にファイルを持っているdoesnot。あなたは、ファイル
$('#btn-upload').click(function(){
var file = $("#cb")[0].files[0];
alert(file); // Shows [object File] i.e. file object
var fileName = $("#cb")[0].files[0].name; // Gives filename
});
var file = $( "#cb")[0] .files [0] .name;ボタンをクリックすると –
はい、それはできませんか? –
何を取得したいですか? –