Reputation: 59
How Can I define an content type with a field that contains an file? I think I should use binary type data to do it that but I don't know how to do the rest... This example uses image upload, but I'm don't know how to define a field as a simple file upload...
Upvotes: 1
Views: 127
Reputation: 175
As Zoltan has written in sensenet there is a predefined content type called File
to handle any kind of file you want. If you inherit your custom CTD from this type (parentType="File"
) it will automatically have a Binary field to store file's binary data when upload and you can define additional fields for custom metas.
If you want to use a content type inherited differently you can use a Binary field to store any kind of data, but will lose built in upload functionality (Upload page
). In the other hand on the New/Edit page there will be the File upload's Browse
button beside your custom field.
With this it's important to set properly the visibility configurations. If it's set to Hide
then you won't be able to upload a file from the New or Edit page.
<Field name="CustomField" type="Binary">
<DisplayName>Custom Field</DisplayName>
<Configuration>
<VisibleBrowse>Hide</VisibleBrowse>
<VisibleEdit>Show</VisibleEdit>
<VisibleNew>Show</VisibleNew>
</Configuration>
</Field>
Upvotes: 2
Reputation: 243
The "File" content type is designed to upload any kind of file. In the example - what you said - described a specialized content type with image related metadata. You should try to use the File content type. If its metadata is not good enough for you, you can create an inherited content type with the desired field set.
Upvotes: 4