diff options
-rw-r--r-- | application/views/file/upload_form.php | 1 | ||||
-rw-r--r-- | data/js/script.js | 15 | ||||
-rw-r--r-- | data/js/upload_form.js | 16 |
3 files changed, 15 insertions, 17 deletions
diff --git a/application/views/file/upload_form.php b/application/views/file/upload_form.php index d92cbfb5c..4d69c69ee 100644 --- a/application/views/file/upload_form.php +++ b/application/views/file/upload_form.php @@ -34,7 +34,6 @@ var max_upload_size = "<?php echo $max_upload_size; ?>"; /* ]]> */ </script> -<script type="text/javascript" src="<?php echo link_with_mtime("/data/js/upload_form.js"); ?>"></script> <?php } else { ?> <?php echo form_open('user/login'); ?> diff --git a/data/js/script.js b/data/js/script.js index e49733b97..b9f60ceea 100644 --- a/data/js/script.js +++ b/data/js/script.js @@ -55,6 +55,21 @@ return this; }); + // check file size before uploading if browser support html5 + if (window.File && window.FileList) { + function checkFileUpload(evt) { + var f = evt.target.files[0]; + if (f.size > max_upload_size) { + document.getElementById('upload_button').innerHTML = "File too big"; + document.getElementById('upload_button').disabled = true; + } else { + document.getElementById('upload_button').innerHTML = "Upload it!"; + document.getElementById('upload_button').disabled = false; + } + } + + document.getElementById('file').addEventListener('change', checkFileUpload, false); + } }); })(jQuery); diff --git a/data/js/upload_form.js b/data/js/upload_form.js deleted file mode 100644 index 111747c67..000000000 --- a/data/js/upload_form.js +++ /dev/null @@ -1,16 +0,0 @@ -// check file size before uploading if browser support html5 -if (window.File && window.FileList) { - function checkFileUpload(evt) { - var f = evt.target.files[0]; - if (f.size > max_upload_size) { - document.getElementById('upload_button').innerHTML = "File too big"; - document.getElementById('upload_button').disabled = true; - } else { - document.getElementById('upload_button').innerHTML = "Upload it!"; - document.getElementById('upload_button').disabled = false; - } - } - - document.getElementById('file').addEventListener('change', checkFileUpload, false); -} - |