mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
@@ -125,6 +125,14 @@ function uploadFile(uid, uploadedFile, callback) {
|
||||
return callback(new Error('[[error:file-too-big, ' + meta.config.maximumFileSize + ']]'));
|
||||
}
|
||||
|
||||
if (meta.config.hasOwnProperty('allowedFileExtensions')) {
|
||||
var allowed = meta.config.allowedFileExtensions.split(',').filter(Boolean);
|
||||
var extension = path.extname(uploadedFile.name).slice(1);
|
||||
if (allowed.length > 0 && allowed.indexOf(extension) === -1) {
|
||||
return callback(new Error('[[error:invalid-file-type, ' + allowed.join(', ') + ']]'));
|
||||
}
|
||||
}
|
||||
|
||||
var filename = uploadedFile.name || 'upload';
|
||||
|
||||
filename = Date.now() + '-' + validator.escape(filename).substr(0, 255);
|
||||
|
||||
@@ -132,13 +132,18 @@
|
||||
<span class="mdl-switch__label"><strong>Allow users to upload regular files</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" data-field="privateUploads">
|
||||
<span class="mdl-switch__label"><strong>Make uploaded files private</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
<strong>Maximum File Size</strong><br /> <input type="text" class="form-control" value="2048" data-field="maximumFileSize"><br />
|
||||
|
||||
<div class="form-group">
|
||||
<label for="maximumFileSize">Maximum File Size</label>
|
||||
<input type="text" class="form-control" value="2048" data-field="maximumFileSize">
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
@@ -146,7 +151,20 @@
|
||||
<span class="mdl-switch__label"><strong>Allow users to upload topic thumbnails</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
<strong>Topic Thumb Size</strong><br /> <input type="text" class="form-control" value="120" data-field="topicThumbSize"> <br />
|
||||
|
||||
<div class="form-group">
|
||||
<label for="topicThumbSize">Topic Thumb Size</label>
|
||||
<input type="text" class="form-control" value="120" data-field="topicThumbSize">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="allowedFileExtensions">Allowed File Extensions</label>
|
||||
<input type="text" class="form-control" value="" data-field="allowedFileExtensions" />
|
||||
<p class="help-block">
|
||||
Enter comma-separated list of file extensions here (e.g. <code>pdf,xls,doc</code>).
|
||||
An empty list means all extensions are allowed.
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user