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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

File Upload cannot delete file

Thread ID:

Created:

Updated:

Platform:

Replies:

145666 Jul 3,2019 03:28 AM UTC Jul 3,2019 07:48 AM UTC ASP.NET Core - EJ 2 2
loading
Tags: File Upload
Wayne
Asked On July 3, 2019 03:28 AM UTC

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)


Wayne
Replied On July 3, 2019 04:01 AM UTC

Fixed it.


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

Prince Oliver [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon