We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

File Upload cannot delete file

I have implemented the file upload using the "chunked" example in combination of the non chunked example.

At first I use the example that is for non chunked and I was able to upload and delete files.

After moving to chunked I can no longer delete / remove files.

I have debugged the Action Method for "Remove" and it does get called but the file list is empty.


I have the following: cshtml

@using Syncfusion.EJ2
@{
    var asyncSettings = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl =   @Url.Content("~/Uploader/Save"), RemoveUrl = @Url.Content("~/Uploader/Remove"), ChunkSize = 500000 }; 
}


<div class="control_wrapper">
<ejs-uploader id="UploadFiles" removing="onFileRemove" dropArea=".control-fluid" asyncSettings="@asyncSettings" maxFileSize="104857600" autoUpload="false" chunkFailure="onBeforeFailure" pausing="onPausing" resuming="onResuming">
</ejs-uploader>
</div>



@section Scripts {
<script>

    function addTokens(args) {
        args.currentRequest.setRequestHeader('XSRF-TOKEN', document.getElementsByName('__RequestVerificationToken')[0].value);
    }

    var dropElement = document.getElementsByClassName('control-fluid')[0];
    function onChange(args) {
        var uploadObj = document.getElementById("UploadFiles")
        uploadObj.ej2_instances[0].asyncSettings.chunkSize = parseInt(args.itemData.chunkValue);
    }
    var isInteraction = false;
    // to update flag variable value for automatic pause and resume
    function onPausing(args) {
        if (args.event !== null && !navigator.onLine) {
            isInteraction = true;
        }
        else {
            isInteraction = false;
        }
    }
    // to update flag variable value for automatic pause and resume
    function onResuming(args) {
        if (args.event !== null && !navigator.onLine) {
            isInteraction = true;
        }
        else {
            isInteraction = false;
        }
    }
    function onFileRemove(args) {
        args.postRawFile = false;
    }
    // to prevent triggering chunk-upload failure event and to pause uploading on network failure
    function onBeforeFailure(args) {
        args.cancel = !isInteraction;
        var uploadObj = document.getElementById('UploadFiles').ej2_instances[0];
        // interval to check network availability on every 500 milliseconds
        var clearTimeInterval = setInterval(function () {
            if (navigator.onLine && !ej.base.isNullOrUndefined(uploadObj.filesData[0]) && uploadObj.filesData[0].statusCode == 4) {
                uploadObj.resume(uploadObj.filesData);
                clearSetInterval();
            }
            else {
                if (!isInteraction && !ej.base.isNullOrUndefined(uploadObj.filesData[0]) && uploadObj.filesData[0].statusCode == 3) {
                    uploadObj.pause(uploadObj.filesData);
                }
            }
        }, 500);
        // clear Interval after when network is available.
        function clearSetInterval() {
            clearInterval(clearTimeInterval);
        }
    }</script>


Here is the action method... UploadFiles Count = 0 for the Delete.
[AcceptVerbs("Post")]
        public IActionResult Remove(IList<IFormFile> UploadFiles)


2 Replies

WA Wayne July 3, 2019 04:01 AM UTC

Fixed it.


function onFileRemove(args) {
        args.postRawFile = true; // must be true to send the file list
    }


PO Prince Oliver Syncfusion Team July 3, 2019 07:48 AM UTC

Hi Wayne,   

Thank you for your update. We are glad that the issue is resolved in your end. Let us know if you need any further assistance on this. 

Regards, 
Prince 


Loader.
Up arrow icon