Stop people from uploading GIF and JPG files in a group forum
Hi!
I have this closed group forum and I want to stop people from uploading gif and jpg files since I prefer using png files. Any recommendations?
Hi!
I have this closed group forum and I want to stop people from uploading gif and jpg files since I prefer using png files. Any recommendations?
This requires programming knowledge on HTML and JavaScript to restrict the file type from submitting. Below is a sample Code written using JavaScript and HTML.
JavaScript Code.
<scripttype="text/javascript">
function CheckFileType(obj) {
var filePath = obj.value;
//Get the file extension from file path
var FileExtension = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();
//Check the extension for invalid formats
if (FileExtension != 'gif' || FileExtension != 'jpg') {
alert('Only png files are allowed');
} else {
document.getElementById('form1').submit();
}
}
</script>
HTML Code.
Assuming that you are using file control to submit files to the server below code is written. You can modify the code according to your requirement.
<form method="post" onsubmit="returnCheckFileType(this.value);">