Hello supporters.
I have try to use your demo "https://js.devexpress.com/Demos/WidgetsGallery/Demo/FileUploader/FileSelection/Angular/Light/", but in updateClick method I can not use this.form.submit() action. I have got this message "error TS2551: Property 'submit' does not exist on type 'NgForm'. Did you mean 'ngSubmit'?"
I have an own project and want to use you file uploader.
Thanks for answer.
Best regards.
Jiri Vesely
In my own project i am using :
<dx-file-uploader
#fileUploader
[uploadUrl]="uploadUrl"
selectButtonText="Select file"
labelText=""
accept="*"
uploadMode="useButtons"
[allowedFileExtensions]="['.xls','.png']"
[uploadHeaders]="headers"
[multiple] ="false"
></dx-file-uploader>
Where
headers: 'Authorization': 'Bearer ' + SecuritySystem.currentUser.auth_token
uploadUrl: `${this.baseUploadUrl}client/uploadfile, uploadfile - background action
[HttpPost, DisableRequestSizeLimit]
public async Task<ActionResult> UploadFile() {
IFormFileCollection files = Request?.Form?.Files;
if (_uow != null && files != null && files.Any()) {
ClientBll clientBll = new ClientBll(_uow);
foreach (IFormFile file in files) {
await clientBll.Import(file);
}
}
return Ok();
}
Request?.Form?.Files - do not contains uploaded file.
https://codesandbox.io/s/xpnpj16yw - not working
Hello Jiri,
>>I have got this message "error TS2551: Property 'submit' does not exist on type 'NgForm'. Did you mean 'ngSubmit'?"
I was unable to reproduce this issue by using Google Chrome Version 73.0.3683.75 (Official Build) (64-bit) and the https://js.devexpress.com/Demos/WidgetsGallery/Demo/FileUploader/FileSelection/Angular/Light/ demo. Would you please modify the demo or prepare a simple project illustrating this error?
>>https://codesandbox.io/s/xpnpj16yw - not working
This example is not working because of the CORS policy which is not directly related to our components. Open the browser's console to check for errors.
In general, you should be able to submit a form by setting the button's type option to submit as described in the Submit the form with ngSubmit article. In our Button widget, the "type" property is used to style the widget in a different manner. However, the type option of an internal element can be set automatically by specifying that the useSubmitBehavior property is set to true:
<dx-button id="button" text="Update profile" [useSubmitBehavior]='true' type="success" (onClick)="updateClick()"> </dx-button>
Please try this approach and let me know of your results.
Thanks,
Alisher
I have use:
<dx-file-uploader
#fileUploader
[uploadUrl]="uploadUrl"
selectButtonText="Select file"
labelText=""
accept="*"
uploadMode="useButtons"
[allowedFileExtensions]="['.xls','.png']"
[uploadHeaders]="headers"
[multiple] ="false"
></dx-file-uploader>
on background method
[HttpPost, DisableRequestSizeLimit]
public async Task<ActionResult> UploadFile() {
IFormFileCollection files = Request?.Form?.Files;
if (_uow != null && files != null && files.Any()) {
ClientBll clientBll = new ClientBll(_uow);
foreach (IFormFile file in files) {
await clientBll.Import(file);
}
}
return Ok();
}
I have get:
Request.Form.Files ; Files = null, Request?.Form?.Files = the function evaluation requires all threads to run