Hi I would like to upload the file with a specific name using uploadcare widget.
For example user on my site select a file to upload using the uploadcare widget embedded in form but I want to give the file selected by user a different name like userID
Is there any way I can do that?
Also I want user to upload images only along with pdf as pdf can be a image as well, how can I do that?
Thanks achernenko.
Actually I have already done that but when I download the file using the code Download’ it still shows the downloaded file name as the original file name uploaded by user.
Is there any way I get the downlaoded file as cat.jpg?
I am wondering if someone can help me . I want to allow only particular extensions file to upload through uploadcare widget.
The custom validation function is working but not outputting the error.
UPLOADCARE_LOCALE_TRANSLATIONS = {
errors: {
'fileType': 'Only image/pdf files are allowed.'
},
dialog: {
tabs: {
preview: {
error: {
'fileType': {
title: 'Upload failed.',
text: 'Only image/pdf files are allowed.',
back: 'Back'
}
}
}
}
}
};
$uc = uploadcare.jQuery;
function fileTypeLimit(types) {
types = types.split(' ');
return function(fileInfo) {
if (fileInfo.name === null) {
return;
}
var extension = fileInfo.name.split('.').pop();
if (types.indexOf(extension) == -1) {
throw new Error("fileType");
}
};
}
$uc('[role=uploadcare-uploader][data-file-types]').each(function() {
var input = $(this);
var widget = uploadcare.Widget(input);
widget.validators.push(fileTypeLimit(input.data('file-types')));
});
});
Its not allowing me to upload any files except mentioned in data-file-types input hidden field but not outputting the error when someone try to upload other extension file like .doc. I am expecting the message ‘Only image/pdf files are allowed.’ on the form near the uploadcare widget field