How to check MIME type before upload in ASP.NET MVC File Upload

26 Aug 20261 minute to read

By using the uploading event, you can get the file MIME type before uploading it to the server.

In this following sample, the file MIME type is shown in an alert before the file starts uploading.

<div class="col-lg-8 control-section">
    <div class="control_wrapper">
        @Html.EJS().Uploader("UploadFiles").Uploading("onBeforeUpload").AutoUpload(false).DropArea(".control-fluid").AsyncSettings(new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "https://services.syncfusion.com/aspnet/production/api/FileUploader/Save", RemoveUrl = "https://services.syncfusion.com/aspnet/production/api/FileUploader/Remove" }).Render()
    </div>
</div>

<script>

    function onBeforeUpload(args) {
        // get the file MIME type
        alert("File MIME type is: " + args.fileData.rawFile.type);
    }

</script>
.control_wrapper {
        max-width: 500px;
        margin: auto;
    }

    .control_wrapper .e-upload .e-upload-drag-hover {
        margin: 0;
    }

Explore the ASP.NET MVC File Upload feature tour page to discover its groundbreaking features. You can also check out our ASP.NET MVC File Upload example to see how to browse and select files for upload to the server.