update,
This commit is contained in:
33
_resources/it114105/ite3905/Assignment/static/js/main.js
Normal file
33
_resources/it114105/ite3905/Assignment/static/js/main.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/* ==========================================
|
||||
SHOW UPLOADED IMAGE
|
||||
* ========================================== */
|
||||
function readURL(input) {
|
||||
if (input.files && input.files[0]) {
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
$('#imageResult')
|
||||
.attr('src', e.target.result);
|
||||
};
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#upload').on('change', function () {
|
||||
readURL(input);
|
||||
});
|
||||
});
|
||||
|
||||
/* ==========================================
|
||||
SHOW UPLOADED IMAGE NAME
|
||||
* ========================================== */
|
||||
var input = document.getElementById( 'upload' );
|
||||
var infoArea = document.getElementById( 'upload-label' );
|
||||
|
||||
input.addEventListener( 'change', showFileName );
|
||||
function showFileName( event ) {
|
||||
var input = event.srcElement;
|
||||
var fileName = input.files[0].name;
|
||||
infoArea.textContent = 'File name: ' + fileName;
|
||||
}
|
Reference in New Issue
Block a user