The file preview disappears after uploading a file. The process uploads to a location not on the server where the site is hosted. The link to the uploaded document is not available after upload, but we are using icons instead of a preview of the file.
Specs: ASPNET MVC C#, Razor pages, Targeting framework 4.6.1,
HTML markup
<div class="row">
<div class="col">
<label>Uploader configured via JS </label>
<div class="file-loading">
<input id="input-js" name="input-js[]" type="file" multiple>
</div>
</div>
</div>
JS and fileinput config
$('#input-js').fileinput({
showUpload: true,
previewFileType: 'image',
dropZoneEnabled: true,
browseOnZoneClick: true,
uploadAsync: true,
theme: 'fas',
uploadUrl: "/Home/FileUpload",
deleteUrl: "/Home/FileDelete",
maxFileCount: 3,
maxFileSize: 240,
maxFilePreviewSize: 10240,
initialPreviewAsData: true,
overwriteInitial: false,
preferIconicPreview: true,
previewFileIconSettings: {
// configure your icon file extensions
'doc': '<i class="fas fa-file-word text-primary"></i>',
'xls': '<i class="fas fa-file-excel text-success"></i>',
'ppt': '<i class="fas fa-file-powerpoint text-danger"></i>',
'pdf': '<i class="fas fa-file-pdf text-danger"></i>',
'zip': '<i class="fas fa-file-archive text-muted"></i>',
'htm': '<i class="fas fa-file-code text-info"></i>',
'txt': '<i class="fas fa-file-alt text-info"></i>',
'mov': '<i class="fas fa-file-video text-warning"></i>',
'mp3': '<i class="fas fa-file-audio text-warning"></i>',
// note for these file types below no extension determination logic
// has been configured (the keys itself will be used as extensions)
'jpg': '<i class="fas fa-file-image text-danger"></i>',
'gif': '<i class="fas fa-file-image text-muted"></i>',
'png': '<i class="fas fa-file-image text-primary"></i>'
},
previewFileExtSettings: { // configure the logic for determining icon file extensions
'doc': function (ext) {
return ext.match(/(doc|docx)$/i);
},
'xls': function (ext) {
return ext.match(/(xls|xlsx)$/i);
},
'ppt': function (ext) {
return ext.match(/(ppt|pptx)$/i);
},
'zip': function (ext) {
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
},
'htm': function (ext) {
return ext.match(/(htm|html)$/i);
},
'txt': function (ext) {
return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
},
'mov': function (ext) {
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
},
'mp3': function (ext) {
return ext.match(/(mp3|wav)$/i);
}
}
});
Json returned from upload
initialPreview: "/Content/greencheckmark.jpg"
initialPreviewAsData: true
initialPreviewConfig: Array(1)
0:
key: "a9483866-251c-4be2-aa49-6f0b5088434d"
caption: "Gas Heating.pdf"
size: 183294
fileId: "a9483866-251c-4be2-aa49-6f0b5088434d"
url: "/Home/FileDelete"
extra:
fileName: "Gas Heating.pdf"
spId: "a9483866-251c-4be2-aa49-6f0b5088434d"
__proto__: Object
type: "pdf"
filetype: "application/pdf"
The JSON response is built per document, 'initialPreviewConfig' is different per document but always with a single value in the array. 'initialPreview' and 'initialPreviewAsData' are the same for all documents.
When a single file is uploaded nothing shows in the preview. When 3 files are uploaded; 2 return correctly one returns a preview with no information view snapshot.
I am lost on what is wrong or why the behavior is inconsistent.
Thank you in advance for assisting with this issue.