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

kendo-upload - files to upload

3 Answers 206 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ziental
Top achievements
Rank 1
ziental asked on 02 May 2018, 04:32 PM

I'm working on a screen where the user will create a record and in the end will add a file to upload.
To resolve this, I disabled the automatic upload and placed the upload on another button (which will be used to save the data and upload).

To do this upload I need the ID, result of the insert, so I do the insert and then I upload using the ID created.

However, when I try to upload through the "xxx" function the list of files to upload is empty.
Follow my code.

<kendo-upload #ParentUploadComp
            [saveUrl]="URL_ParentUpload"
            [autoUpload]="false"
            [restrictions]="UploadImageRestrictions"
            [multiple]="false"
            [removeUrl]="uploadRemoveUrl"
            [(ngModel)]="ImageParentFiles">
</kendo-upload>

 

@ViewChild('ParentUploadComp') ParentUploadCompRef: any;
ImageParentFiles: Array<FileInfo> = [];

 

this.ParentUploadCompRef.uploadFiles();

 

When I use the above code, the variable "ImageParentFiles" is coming null, and is not uploaded.

Anyone have any suggestions?

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 03 May 2018, 06:53 AM
Hi Zdzislaw,


I am not sure what type of back-end technology is being used. As a shot in the dark, if you are using ASP.NET MVC, make sure that the name of the parameter in the handler receiving the files, is the same as the name attribute of the Upload underlying <input type="file" /> element. By default it is named files, but it could be changed by specifying the saveField property of the component.

https://www.telerik.com/kendo-angular-ui/components/upload/api/UploadComponent/#toc-savefield


Regards,
Dimiter Madjarov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
ziental
Top achievements
Rank 1
answered on 07 May 2018, 05:05 PM
@ViewChild('ParentUploadComp') ParentUploadCompRef: any;

I saw that the list of files were being saved in variable "ParentUploadCompRef.fileList.files".

For the upload trigger to work, I had to set variable saveField to this list of files, and set the contents of the saveUrl variable to the URL that will be used to upload.
The final code looks like this.

@ViewChild('ParentUploadComp') ParentUploadCompRef: any;
this.ParentUploadCompRef.saveField = this.ParentUploadCompRef.fileList.files;
this.ParentUploadCompRef.saveUrl = this.URL_ParentUpload;
this.ParentUploadCompRef.uploadFiles();

 

Thank you for your help.

0
Dimiter Madjarov
Telerik team
answered on 08 May 2018, 07:13 AM
Hi Zdzislaw,


Only invoking the uploadFiles method is sufficient for manually uploading the currently selected files.

Regards,
Dimiter Madjarov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
ziental
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
ziental
Top achievements
Rank 1
Share this question
or