Base solution for your next web application
Open Closed

Uploading a File MVC Core #11518


User avatar
0
[email protected] created

Hey Team,

The project template I'm working with is as follows:

  • ANZ 12.0.0*
  • Template - MVC Core & jQuery*
  • Database - MSSQL*
  • ORM - EF Core

I think I've completely misconstrued the "file" datatype option using Power Tools. I was expecting to be able to upload a file or image and that datatype be of varbinary(max) or something similar. When looking at the entity there is just a virtual property set to a Guid, Int or whatever option I select as the PK. Ultimately, what I'm needing is to figure out a way that I can have 4 images associated with a single animal. So, in other words, the user will select their animal and upload 1 - 4 images which will be stored in the database and associated with that animal. I hope I'm making sense in all this. Again, thank in advance for your help.


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

    Hi,

    Yes, you can add 4 different file type fields to your entity using Power Tools. Those files are stored in a different table named AppBinaryObjects and linked to main entity with a FK field. So, this is totally fine and you can use it that way.

  • User Avatar
    0
    [email protected] created

    Thanks for your response. It seems that either I’m missing something or there’s a bug with Power Tools then. I create an entity property named Photo with the data type of “file” from Power Tools. I then complete the rest of the entity design and click the generate button. All goes well. Now, when I run the application, go to the new entity and chose a file to upload. All that happens is I’m prompted to select my file and then click open. I finish entering in all the rest of the fields and click save. The file is not saved anywhere. I checked the location you specified in your response as well. Now, if I select a new profile image and save it, it works. So I’m wondering if there’s a bug with Power Tools generation?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Is it possible to share a screen recording for this problem ? You can use https://www.screentogif.com/.

  • User Avatar
    0
    [email protected] created

    I will attempt to record for you, however, other than showing it isn’t working not sure of the benefit. I’ve followed instructions 100% to the letter. Am I to understand that you have no problems using Power Tools, creating an entity with a file data type and upload works?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Yes, we tested this funcionality recently and it works as expected. But, in some rare cases, there might be problems. If you want, you can also share your generated JSON files for the entity (under apsnet-core/AspNetZeroRadTool folder) and we can also test it locally.