Click here to Skip to main content
16,004,507 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get value of file path of input element (file type) in openui5 controller. I can use native html controller in xml view but struggle with "controlling" them.

What I have tried:

Successfully inserted native html element into openui5 view. It's working in terms of choosing files and even opening camera to take picture. I'm now trying to read file chosen by input element in js controller but it doesn't seem to work. I can fetch object with var imageInput = this.getView().byId("imageInputId"); ... That returns object of type XMLView, but i cannot get its attributes e.g. imageInput.files[0]. That's undefined.
Posted
Updated 12-Mar-18 1:14am
Comments
F-ES Sitecore 12-Mar-18 7:29am    
You won't be able to get the path to the file for security reasons. If you want to read the file you'll need to use the html5 file api. Google "html5 file api" for examples.

1 solution

Hi,


Can You try as below, I haven't tested this code it just way to do.


HTML
<u:FileUploader
id="fileUploader"
name="myFileUpload"
uploadUrl="upload/"
tooltip="Upload your file to the local server"
uploadComplete="handleUploadComplete"
change="handleValueChange"
...


JavaScript
Controller.extend('FileUploaderComplez.Controller', {
   handleValueChange: function(oEvent){
          //oEvent is fileupload events can have fileContent
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900