web-mooc/resources/views/instructor/course/create_media.blade.php

38 lines
1.6 KiB
PHP

<div class="row mb-3">
<label for="thumbnail" class="form-label ol-form-label col-sm-2 col-form-label">{{get_phrase('Thumbnail')}}</label>
<div class="col-sm-10">
<input type="file" name="thumbnail" class="form-control ol-form-control" id="thumbnail" accept="image/*" />
</div>
</div>
<div class="row mb-3">
<label for="banner" class="form-label ol-form-label col-sm-2 col-form-label">{{get_phrase('Banner')}}</label>
<div class="col-sm-10">
<input type="file" name="banner" class="form-control ol-form-control" id="banner" accept="image/*" />
</div>
</div>
<div class="row mb-3">
<label for="preview" class="form-label ol-form-label col-sm-2 col-form-label">{{get_phrase('Preview Video')}}</label>
<div class="col-sm-10">
<input type="file" name="preview" class="form-control ol-form-control" id="preview" accept="video/*" />
</div>
</div>
<script type="text/javascript">
"use strict";
document.getElementById('thumbnail').addEventListener('change', function(event) {
const file = event.target.files[0]; // Get the selected file
const maxSize = 2 * 1024 * 1024; // 2 MB in bytes
// Get the message from Laravel's get_phrase function
const maxFileSizeMessage = '{{ get_phrase('The maximum file size is 2 MB.') }}';
if (file && file.size > maxSize) {
// If the file is larger than 2 MB, show an alert and reset the input
alert(maxFileSizeMessage); // Use the translated message
event.target.value = ''; // Clear the selected file
}
});
</script>