Custom form: how to attach file?

Topics: General
Aug 6, 2014 at 10:06 AM
I made a Custom Form for feedback.
How I can to attach file to feedback form for Anonymous role?
Media Picker is not working.
Aug 6, 2014 at 11:58 AM
Edited Aug 6, 2014 at 12:04 PM
I am also looking for this functionality. I guess there are some existing fields that you can use, but they need updating. I was working on updating the Ajax File uploader field. But I think a simple input field would also suffice.

Maybe take a look at the deprecated image pickerfield. I think it might be pretty simple to create a standard input type=file field, while looking at the code of the Orchard.Fields module.

Alternatively there is the existing secure file field, but I think it is maybe a bit overdue for your functionality demands.

Let me know if you find anything.
Aug 7, 2014 at 6:54 AM
As I expected, it was pretty simple to convert the old File Field to a working field in Orchard 1.8.1.

The main 'issue' was that the old file field was using the Media service, which is not usable anymore. For storing files the IStorageProvider must be used.
I encourage you to convert the file field for your own, as you will learn a lot about it (I did anyway, cause I'm still a newbie at orchard).

I don't know what you will do with the custom form, but the most common functionality of an input field is storing the file on the server and store the url in the database. If it is a contact form (as feedback form suggests) I think you maybe want to email it and not store it on the server, so you'll have to convert the file to bytes to send it.

Good luck!
Sep 16, 2014 at 3:45 PM
Hello sir!

I'm also quite the newbie at Orchard and I'm having difficulty getting this working.

Both the FileField and SecureFileField attempt to utilize the Media module--how do you go about having it reference the proper assemblies?
Sep 16, 2014 at 4:17 PM
If I remember correctly I just downloaded the Contrib.FileField, created a new Orchard module and copied over the classes of the Contrib.FileField.

Then I just refactored all build errors. The most part was the driver I think, which uses IMediaService which is deprecated. I just replaced it with the IStorageProvider.
Sep 16, 2014 at 4:20 PM
Awesome and thank you so much for the reply.

Going to have to give this a try. :)