Hi Dw's,
How can we upload a file with the ItemCreator? Right now it seems to be through the FileManager, but that doesn't seem to be a good option in the frontend.
Best regards, Anders
Hi Dw's,
How can we upload a file with the ItemCreator? Right now it seems to be through the FileManager, but that doesn't seem to be a good option in the frontend.
Best regards, Anders
Currently, you cannot upload a file using the item creator (or when editing an item using the item publisher) in the frontend and using the FileManager is not the way to do it.
We are working on figuring out how to handle file fields in the frontend, and we've been discussing if a file field should be just a file selector (e.g. a dropdown list) or if should also support uploading files. It probably should support uploading files, but we will need some additional settings on the field to control if uploading is allowed or not and if picking a file is allowed or not. Any suggestions and comments on this is very welcome.
Best regards,
Mikkel
Hi Mikkel,
I certainly think that it should support uploading files where the settings for BaseDirectory and Extensions set on the field should be respected. As it then can replace the form modules.
Best regards, Anders
Thanks. We have specified this task and a couple of related tasks, and we'll start implementing next week.
Best regards,
Mikkel
We're currently working on this feature and it will be availablie in Dynamicweb 8.5.
Best regards,
Mikkel
Thanks, I will look forward to that
I just looked at the roadmap, and I couldn't find this new feature inside the roadmap. Will this feature still be a part of the release?
Yes, file uploads in the Item creator will be supported in Dynamicweb 8.5.
Best regards,
Mikkel
cool :-)
Now that DW 8.5 has been releases I have been looking for this new file upload feature but with no luck! Mikkel could you please show me where to find it? Thanks.
As the release notes hint at you just have to add some markup to your item creator template to allow upload of files.
An example template looks like this:
@GetValue("ItemCreator:Edit.Form.Begin") @foreach (var group in GetLoop("ItemCreator:Edit.Item.Groups")) { <fieldset> <legend>@group.GetValue("ItemCreator:Edit.Item.Group.Name")</legend> <dl> @foreach (var field in group.GetLoop("ItemCreator:Edit.Item.Group.Fields")) { <dt>@field.GetValue("ItemCreator:Edit.Item.Field.Name")</dt> <dd> @field.GetValue("ItemCreator:Edit.Item.Field.Control") @if (field.GetString("ItemCreator:Edit.Item.Field.EditorType").Contains("Dynamicweb.Content.Items.Editors.FileEditor")) { <input type='file' name='@field.GetValue("ItemCreator:Edit.Item.Field.SystemName")' accept='@field.GetValue("ItemCreator:Edit.Item.Field.Extensions")'/> } </dd> } </dl> </fieldset> } <button type='submit'>Create</button> @GetValue("ItemCreator:Edit.Form.End")
The important part is
<input type='file' name='@field.GetValue("ItemCreator:Edit.Item.Field.SystemName")' accept='@field.GetValue("ItemCreator:Edit.Item.Field.Extensions")'/>
Best regards,
Mikkel
Hi Mikkel
Thanks for the superb example. Would have been nice if it was shown in the release note. I didn't understand the explanation in the release note, I think it could have been explained a lot clearer :-)
Ok, but it will be a field just as richtext, text etc. No serverside coding needed?
It has to be a File field and you have to add a file input control as shown in the example. That's all.
Ok, maybe I´m gonna need you to ellaborate if we get this client.
Hey,
Used the above for the ItemCreator without any problem - but how would I go about making the same functionality in the ItemPublisher edit instead?
@GetValue("ItemPublisher:Edit.Form") Gives me all the text fields which changes fine on a "Save Changes" and it also list the image chosen in a dropdown - however nothing changes if you change it "Nothing selected".
If I then instead use the ItemPublisher:Edit:Form.Begin and ItemPublisher:Edit:Form.End it seems I only have a loop for the images in the dropdownlist and not a list of all fields as I would expect?
You must be logged in to post in the forum