cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

UploadCollection: Delete the attached files.

agrawalaadhar8
Participant
0 Kudos
2,281

Hi All,

I am using one UploadCollecition control since I need to add one file for upload to my app and in the end, i.e. when user press Approve button, only then the file upload is done.

How can I limit the number of files uploaded since I only want one file to be uploaded.

Also I tried in the Change event of UploadCollection by comparing the length and if GE 1, delete the file in frontend only but couldn't figure out.

Please Help..

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

maheshpalavalli
Active Contributor

Hi Shubh Agarwal,

You do not need to delete any newly added item, you can simply disable the add button when the user adds the new attachment for the first time in the change event.

Also, you can have a look at the below file uploader which actually allows only one file to be uploaded.

https://ui5.sap.com/#/api/sap.ui.unified.FileUploader

BR,

Mahesh

agrawalaadhar8
Participant
0 Kudos

Currently I am removing All Items from the uploadCollection in Change() event and by that only the last uploaded file is available.

maheshpalavalli
Active Contributor
0 Kudos

Hi Shubh,

Then simply use the FileUploader that I've mentioned in the answer.. It even shows that it will upload on click of upload button.

BR,

Mahesh

agrawalaadhar8
Participant
0 Kudos

Hi Mahesh,

I am using FileUploader now, but when i upload an xlsx file, the file that is sent to backend in is_media_resource is not getting correct file. When I convert the XSTRING TO BINARY the length is not coming correct.

However if I use UploadCollection it is working fine..

Can you suggest how can i overcome that problem since i want to use fileuploader only.

Thanks

maheshpalavalli
Active Contributor
0 Kudos

There is one property called useMultiPart, you have to set it as false.. then the data will correctly go else data will go in a different format, which I think is the cause of your issue.

BR,

Mahesh

agrawalaadhar8
Participant
0 Kudos

Hi Mahesh,

Yes Working Now...

Thanks So Much 🙂

Answers (1)

Answers (1)

anudeep_paleru
Explorer

Hi ,

Below works exactly same as Upload Collection but with File Uploader.

<u:FileUploader style="Emphasized" uploadUrl="/EntitySet" id="fileUploader" name="myFileUpload" buttonText="Upload" buttonOnly="true" change="handleFileValueChange" uploadOnChange="false" uploadComplete="handleFileUploadComplete"/>

agrawalaadhar8
Participant
0 Kudos

Will try that.

I need to upload the file only when Approve button is clicked and before that the user may upload same/different file several times, so will it take only the last file?