Skip to Content
Technical Articles
Author's profile photo Amita Jain

Simple file upload using file uploader directly backend

This blog illustrates the best practice on how to import Data CSV, XLS,XLSX,JPEG etc upload on backend from UI5 without writing long code or use of third party API’s.


I have been looking for code where I can upload excel, images/text files without writing much javascript codes and requirement was not display the data on screen as well, direct upload.

Here, I have used simple File Uploader Controller latest version, to demonstrate. I have used the SAP walkthrough code with odata example and in real application situation

XML code

In filetype property you can set all the media types you wanted to allow your file upload code like fileType=”JPEG,CSV,XLSX”. other properties can be referenced from


<mvc:View controllerName="comZcsvTest.controller.View1" xmlns:html="" xmlns:mvc="sap.ui.core.mvc"
displayBlock="true" xmlns="sap.m" xmlns:u="sap.ui.unified" xmlns:l="sap.ui.layout">
<Page title="{i18n>title}">
<Text text="hello"/>
<u:FileUploader id="idfileUploader" width="50%" sameFilenameAllowed="false" useMultipart="false" uploadUrl="/sap"
placeholder="Choose a CSV file" style="Emphasized"></u:FileUploader>
<Button text="Upload" press="uploadFile"/>


Controller code


In controller code, I have written simple lines of code to upload the files/media on CREATE_STREAM method, used addHearParameter and destroy Parameter method, As I found without destroy slug values are getting concatenated.

In method afterUploadCompleted, You can display message using “response”“response”);

], function(Controller) {
"use strict";

return Controller.extend("comZcsvTest.controller.View1", {
uploadFile: function(oEvent) {
var oFileUploader = this.getView().byId("idfileUploader");
this.csrfToken = this.getView().getModel().getSecurityToken();
var headerParma = new sap.ui.unified.FileUploaderParameter();
var headerParma2 = new sap.ui.unified.FileUploaderParameter();
oFileUploader.checkFileReadable().then(function() {
}, function(error) {"The file cannot be read. It may have changed.");
}).then(function() {
afterUploadComplete: function(oEvent) {
var response = oEvent.getParameters("response");



media will upload without any third party api’s , Also code can be used for kind of media upload and supports latest SAP UI5 file upload control as well as older

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo FIRAT ASAN

      Hello Amita, thank you for your article. This is very clean and understandable code.