I have ArcGIS Server 11.5 with the following configuration:
I can upload feature attachments (up to 20MB) using the following function called popup action.
The function is:
function _addAttachment(feature: any) {
//create form
const attachmentForm = document.createElement("form");
attachmentForm.setAttribute("id", "attachmentForm");
let fileSelector = document.createElement("input");
fileSelector.setAttribute("id", "fileInput");
fileSelector.setAttribute("type", "file");
fileSelector.setAttribute("name", "attachment");
fileSelector.setAttribute("accept", "image/*,video/*,application/pdf");
let entInput = document.createElement("input");
entInput.setAttribute("name", "f");
entInput.setAttribute("value", "json");
attachmentForm.appendChild(fileSelector);
attachmentForm.appendChild(entInput);
document.body.appendChild(attachmentForm);
document.getElementById('fileInput')?.addEventListener("change", (e) => {
let uploadedFile = (e.target as any).files[0];
if (!uploadedFile) {
let message = "No file has been selected.";
(document.getElementById("calcite-error-content") as any).innerHTML = message;
(document.getElementById("calcite-error-modal") as any).open = true;
return;
}
const formData = new FormData(attachmentForm);
console.log(formData);
// The attachment is taken from the form.
feature.layer.addAttachment(feature, formData).then((result: any) => {
if (result.error === null) {
alert("Attachment has been successfully uploaded.");
}
//delete form node
document.body.removeChild(document.getElementById("attachmentForm") as any);
}).catch((error:any) => {
//delete form node
document.body.removeChild(document.getElementById("attachmentForm") as any);
console.log("attachment adding failed: ", error);
alert("Attachment upload has failed.");
});
});
document.getElementById('fileInput')?.click();
}
I tried for file size of 170MB and fails with 500 error code.
I appreciate for any work aroun
Solved! Go to Solution.
Error in my IIS setup of maxAllowedContentLength. increased to 2GB and works fine
Error in my IIS setup of maxAllowedContentLength. increased to 2GB and works fine