File Upload in Module Classes

Ben Janssen asked on June 19, 2018 21:54

Kentico 11

I would like to add a file upload/attachment field to the Membership Module in the User-Settings class.

I would want users to be able to upload a document(pdf, docs, jpg, etc.) and save it into the database. Users would only be able to see their personal upload. (add, delete, replace).

I have been looking through the field type options and control options and haven't found a useful configuration yet. In fact, I wasn't able to create a binary field without an error.


Recent Answers

Peter Mogilnitski answered on June 19, 2018 22:28

You need to set data type to file

0 votesVote for this answer Mark as a Correct answer

Ben Janssen answered on June 19, 2018 22:43

Hi Peter,

There is no "file" data type in the User Settings class. Maybe its disabled? In which case maybe I need to make a new class and bind to it?

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on June 20, 2018 03:04 (last edited on June 20, 2018 14:33)

Yup. You are right. My bad, it was not that obvious, but... you have to experiment here.

  1. You can go to form controls
  2. find upload control (I guess this one you looking for) and enable it for text and system tables.
  3. Now go back to module -> classes -> user settings -> fields and add new field text - choose text.
  4. For form control click more items... -> choose upload. Here is the trick - The text type will be replace with file. Now you have a field which is file and uses the upload control.

Now you can go to users, pick any user and you can see this. it should give the idea how to approach this issue: Enabling form control and try it out. The upload it will not work "out of the box", because it is meant to work with forms, but you can clone it and customize its behavior. By default it saves files to site code name/BizFormFiles/ folder. You might as well try other uploaders from controls: just check which one is easier to customize for your needs.

P.S. On second thought: You can always use selection controls: file selector, url selector etc, they will keep path to your file. You can have a folder where all users files are and keep path to a file for an individual user.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.