1
My question is regarding File Upload using the http://plugins.krajee.com/file-input
I have the following JS code
$('#arquivoCliente').fileinput({
language: 'pt-BR',
uploadAsync: false,
showPreview: false,
maxFileSize: 200,
uploadUrl: 'upload.php',
allowedFileExtensions : ['PDF', 'pdf']
uploadExtraData: function() {
return {
id: tempIDCliente
};
}
});
My php is all ok, it’s saving the file and everything. What I can’t do is. As you can see my code is set to accept only the PDF extension. If the user chooses another extension, the send button is disabled.
However this option is only working if I comment on the uploadUrl line, as in the example below.
$('#arquivoCliente').fileinput({
language: 'pt-BR',
uploadAsync: false,
showPreview: false,
maxFileSize: 200,
// uploadUrl: 'upload.php',
allowedFileExtensions : ['PDF', 'pdf']
uploadExtraData: function() {
return {
id: tempIDCliente
};
}
});
But what do you want? Just remembering that the Javascript of this plugin works like this!
– novic
Hi @Virgilionovic I did the following, disabled in fileuploaderror, $('#fileCliente'). on('fileuploaderror', Function(Event, data, msg) { var form = data.form, files = data.files, extra = date.extra, Response = data.Response, Reader = data.Reader; console.log('File upload error'); // get message alert(msg, 'Danger'); $('.fileinput-upload-button').attr('disabled', 'disabled'); }); ?
– Rafael Weber
So did you manage to solve? if yes put as answer!
– novic
Actually I don’t know if that’s so. It worked, but I don’t know if it was a great gambit.
– Rafael Weber
Maybe it’s not guambiarra, maybe it’s a bug, and it’s bypassed!
– novic
If it has repository on github maybe open an Issue and tell them the problem is a good one! https://github.com/kartik-v/bootstrap-fileinput
– novic
I’m going to put my resolution as an answer here and do this.
– Rafael Weber
Thank you @Virgilionovic
– Rafael Weber