Base solution for your next web application
Open Closed

Uploading files with Aspnet Zero + Angular 6 #5775


User avatar
0
larsfk created

Hi!

I'm trying to get fileupload to work. Im using the DemoUiComponent-file uploader, but cant figure out where and how the files are uploaded. Can't find any good documentation on it either.

Please help :)

Thanks!


10 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi,

    You can see the code for uploading profile image.

    https://github.com/aspnetzero/aspnet-zero-core/blob/8672111621dffd72f96a2e4f8670d9584568b29a/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Core/Controllers/ProfileControllerBase.cs#L28

  • User Avatar
    0
    larsfk created

    Thank you! Is the image saved on the server or in the database?

  • User Avatar
    0
    alper created
    Support Team

    being saved on the server.

  • User Avatar
    0
    larsfk created

    Is there any examples on downloading files?

  • User Avatar
    0
    alper created
    Support Team

    As far as I remember, there's no. But it's simple. You know where your uploaded file is (eg: C:\inetpub\wwwroot\MyProject\uploads\abc.jpg) create a link like myproject.com/uploads/abc.jpg.

  • User Avatar
    0
    larsfk created

    My problem is that I cant find my files. I see that a BineryObject is created and stored in the database, but cant find any files on locally at the host...

  • User Avatar
    1
    alper created
    Support Team

    the profile image upload seems like it's storing files in database. So follow this tutorial https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-2.1

  • User Avatar
    0
    larsfk created

    I got uploading to work with the DemoUiComponentsController, but when extending FileController with HttpPost-method UploadFiles I just get 500 when trying to post there. Am I missing something?

    I tried changing

    this.uploadUrl = AppConsts.remoteServiceBaseUrl + '/DemoUiComponents/UploadFiles';

    to

       this.uploadUrl = AppConsts.remoteServiceBaseUrl + '/File/UploadFiles';
    

    without any luck...

  • User Avatar
    0
    larsfk created

    Got it to work. Was a bug in my constructor.

  • User Avatar
    0
    AstarIT created

    Can you share the code, I have the same situation here. I try to upload files to my server. All help will be really appreciated. Thank you