Merge pull request #829 from Squidly271/patch-25

Only allow png files to be uploaded as user image
This commit is contained in:
tom mortensen
2021-05-05 12:55:07 -07:00
committed by GitHub
3 changed files with 8 additions and 4 deletions
+2 -2
View File
@@ -113,7 +113,7 @@ $(function(){
url:'/webGui/include/FileUpload.php',
data:{path:path,"csrf_token":"<?=$var['csrf_token']?>"},
beforeEach:function(file) {
if (!file.type.match(/^image\/.*/)) {
if (!file.type.match(/^image\/png/)) {
swal({title:"Warning",text:"Only PNG images are allowed!",type:"warning",html:true,confirmButtonText:"_(Ok)_"});
return false;
}
@@ -169,7 +169,7 @@ _(Description)_:
:user_add_description_help:
_(Custom image)_:
: <span id="dropbox"><?=$void?></span><em>_(Drag-n-drop a PNG file or click the image at the left)_</em><input type="file" id="drop" accept="image/*" style="display:none">
: <span id="dropbox"><?=$void?></span><em>_(Drag-n-drop a PNG file or click the image at the left)_</em><input type="file" id="drop" accept="image/png" style="display:none">
:user_add_custom_image_help:
+2 -2
View File
@@ -119,7 +119,7 @@ $(function(){
url:'/webGui/include/FileUpload.php',
data:{"csrf_token":"<?=$var['csrf_token']?>"},
beforeEach:function(file) {
if (!file.type.match(/^image\/.*/)) {
if (!file.type.match(/^image\/png/)) {
swal({title:"Warning",text:"_(Only PNG images are allowed)_!",type:"warning",html:true,confirmButtonText:"_(Ok)_"});
return false;
}
@@ -180,7 +180,7 @@ _(Custom image)_:
<?else:?>
<?=$void?>
<?endif;?>
</span><em>_(Drag-n-drop a PNG file or click the image at the left)_</em><input type="file" id="drop" accept="image/*" style="display:none">
</span><em>_(Drag-n-drop a PNG file or click the image at the left)_</em><input type="file" id="drop" accept="image/png" style="display:none">
:user_edit_custom_image_help:
+4
View File
@@ -79,6 +79,10 @@ div.case-name{margin-top:8px;font-family:clear-sans!important}
<script src="<?autov('/webGui/javascript/dynamix.js')?>"></script>
<script>
function importFile(file) {
if (file.name.split(".").pop().toLowerCase() !== "png") {
alert("<?=_("Only png images are allowed!")?>");
return;
}
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function(e){$.post('/webGui/include/SelectCase.php',{mode:'file',file:'<?=$file?>',data:e.target.result,csrf_token:'<?=$_GET['csrf']?>'},function(){top.Shadowbox.close();})};