Add file upload to Orchard module?
Asked Answered
M

2

7

Hi i'm currently working with the CyberStride.Contacts module in Orchard and have been trying to add a file upload to the form, but there seems to be a problem somewhere because the files never upload. Has any one successfully add a fileupload to a module in Orchard, if so could you share how you accomplished this. Thanks.

Mcquiston answered 22/2, 2011 at 22:54 Comment(0)
R
3

In order to be able to upload with a form, that form needs to be multipart. This is why it doesn't work without a couple of tricks.

You can find an example of a file upload in this module: http://orchardproject.net/gallery/List/Modules/Orchard.Module.Contrib.ImageField

Rhomboid answered 23/2, 2011 at 4:27 Comment(3)
Bertrand, any chance you could elaborate on the "couple of tricks"? I checked out Contrib.ImageField and found the javaScript that sets the enctype and encoding for the form, and I've got that, but still nothing in Request.Files. I'm posting to my own controller not a driver (similar pattern to the Orchard.Search module). Could that be a factor? Anyway, thanks for Orchard CMS and all your articles and answers on it. Very cool stuff.Zena
That should be it. I'm not sure what is happening in your case. Looking at working code is definitely the way to achieve this.Rhomboid
The link is now gallery.orchardproject.net/Packages/…Rhomboid
D
2

Note now there is a FileUpload field here: http://orchardproject.net/gallery/List/Modules/Orchard.Module.Contrib.FileField

Once you install this

  1. Click Content Types on the dashboard.
  2. Click Edit on the Contact Page type.
  3. Under fields, click Add, and add File Field. Thats it!!

When you add a contact form a file upload field will automatically show.

Despinadespise answered 1/4, 2011 at 14:13 Comment(1)
gallery.orchardproject.net/Packages/… should work.Rhomboid

© 2022 - 2024 — McMap. All rights reserved.