Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to use p-fileupload to save image? #4251


User avatar
0
manojreddy created

I'm trying to use primeng fileupload. But I'm not able to find out how to save the uploaded image on some given path.

<p-fileUpload multiple="multiple"
                                  name="DefaultFileUploadFileInput[]"
                                  [url]="uploadUrl"
                                  accept="image/*"
                                  maxFileSize="1000000"
                                  (onUpload)="onUpload($event)">

                        <ng-template pTemplate="content">
                            <ul *ngIf="uploadedFiles.length">
                                <li *ngFor="let file of uploadedFiles">{{file.name}} - {{file.size}} bytes</li>
                            </ul>
                        </ng-template>
                    </p-fileUpload>
uploadUrl: string;
    uploadedFiles: any[] = [];

    constructor(
        injector: Injector,
        private demoUiComponentsService: DemoUiComponentsServiceProxy
    ) {
        super(injector);
        this.uploadUrl = AppConsts.remoteServiceBaseUrl + '/DemoUiComponents/UploadFiles';
    }

    // upload completed event
    onUpload(event): void {
        for (let file of event.files) {
            this.uploadedFiles.push(file);
        }
    };

3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can check the sample controller, <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Core/Controllers/DemoUiComponentsController.cs#L24">https://github.com/aspnetzero/aspnet-ze ... ler.cs#L24</a>.

    You can create a similar controller for your use case and save received files into a path you want.

  • User Avatar
    0
    manojreddy created

    Hi I'm getting 404 error for <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Core/Controllers/DemoUiComponentsController.cs#L24">https://github.com/aspnetzero/aspnet-ze ... ler.cs#L24</a> . Already added git user name in <a class="postlink" href="https://aspnetzero.com/LicenseManagement">https://aspnetzero.com/LicenseManagement</a> .

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It seems liek you haven't accepted the invitation yet. Please visit this address to accept invitation <a class="postlink" href="https://github.com/orgs/aspnetzero">https://github.com/orgs/aspnetzero</a> while you are logged in on github.