This is a migrated thread and some comments may be shown as answers.

File upload display file

5 Answers 490 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hadas
Top achievements
Rank 1
Hadas asked on 22 Oct 2018, 10:59 AM

Hi,

I am using kendo-upload an I am looking for the option to view the file after the user uploads it, I want to be able to click on the file name and the file will then be displayed/ downloaded.

Is there any way to get this behaviour?

 

Thank you!

5 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 23 Oct 2018, 07:15 AM
Hello Hadas,


A possible way to achieve this is to bind the uploaded files via ngModel - this way there will be no need to download the file after it has been uploaded in order to display it. Displaying the file could be achieved via file reader on the client side. Here is an example of this in action, in which I used the following resources of the documentation:

File templates - https://www.telerik.com/kendo-angular-ui/components/upload/templates/

Model binding - https://www.telerik.com/kendo-angular-ui/components/upload/model-binding/

Regards,
Dimiter Madjarov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Hadas
Top achievements
Rank 1
answered on 05 Nov 2018, 10:58 AM

Thank you for you reply.

Your example only works for a .jpg file... I need to be able to upload all file types (and display them), can you advice how to do it?

Thanks in advance

0
Dimiter Madjarov
Telerik team
answered on 05 Nov 2018, 11:08 AM
Hi Hadaz,


The FileReader could be used to read the content of any file type by using the appropriate method

https://developer.mozilla.org/en-US/docs/Web/API/FileReader#Methods

but displaying the content would be strictly specific and will most probably require a third party library to achieve it.

Regards,
Dimiter Madjarov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Hadas
Top achievements
Rank 1
answered on 13 Nov 2018, 07:07 AM

I am wondering if there is another way to accomplish this without overriding / changing the telerik template?

If that's not possible can we have the html for telerik template so I can use it in my code and just add the click event ?

Thanks

0
Svet
Telerik team
answered on 14 Nov 2018, 02:57 PM
Hi Hadas,

Indeed, some custom implementation will be needed in order to achieve the desired behavior. You can check the source code of any Kendo Ui for Angular package by following the instructions on the following page:
https://www.telerik.com/kendo-angular-ui/components/installation/source-code/

Regards,
Svetlin
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Hadas
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Hadas
Top achievements
Rank 1
Svet
Telerik team
Share this question
or