I am using the WebForm module to allow anonymous guests to the website upload files. They are usually pdfs and some may have 1 and some may have 8. The Webform Module works great, I just would like an option to add another file. Kind of like the attachments portion. I have noticed there is a components directory so if anyone has any ideas of how to make a component or has the patience to work me through creating one, I would be more than happy to help. It seems like there must be some way to make this happen.

I have read through articles about doing this with CCK but I have no idea how to get that to work, Webform seems much simpler and does what I need , I just need to modify it a bit, Any help would be appreciated!

CommentFileSizeAuthor
#35 i623692.patch1.41 KBattiks

Comments

gogowitsch’s picture

Version: 6.x-3.x-dev » 6.x-2.8
Priority: Normal » Minor

Here is a file to start from: http://blaeul.de/multifile.zip

Extract both files in the archive in your modules/webform/components directory, and a new multifile type will be available when you create new components for a webform.

Maybe it'll find its way into the webform module. The javascript is from http://www.fyneworks.com/jquery/multiple-file-upload, the Drupal code by myself.

Edit: This component was developed for webform 2.9. It likely works with all 2.x versions of webform, which are now considered insecure. The fix from #7 below has been included in the zip download above.

joshfromdallas’s picture

Cool, works great and exactly what I need. Awesome work!!! I hope this gets put into the webform module!

Only mods on my wish list would be a progress bar during upload

and in the email notification I have it send the person the Files show up with all sorts of stuff:

a:2:{i:0;O:8:"stdClass":10:{s:8:"filename";s:33:"TEST
PDF Table 1 6-12-08.pdf";s:8:"filepath";s:72:"sites/default/files/webform/uploadform/TEST
PDF Table 1 6-12-08.pdf
";s:8:"filemime";s:15:"application/pdf";s:6:"source";s:6:"files0";s:11:"destination";s:72:"sites/default/files/webform/uploadform/TEST
PDF Table 1 6-12-08.pdf";s:8:"filesize";i:60189;s:3:"uid";s:1:"1";s:6:"status";i:1;s:9:"timestamp";i:1264435921;s:3:"fid";s:2:"50";}i:1;O:8:"stdClass":10:{s:8:"filename";s:53:"TEST
PDF Table 2 6-12-08.pdf.pdf";s:8:"filepath";s:92:"sites/default/files/webform/uploadform/TEST
PDF Table 2 6-12-08.pdf";s:8:"filemime";s:15:"application/pdf";s:6:"source";s:6:"files1";s:11:"destination";s:92:"sites/default/files/webform/uploadform/TEST
PDF Table 2 6-12-08.pdf";s:8:"filesize";i:135481;s:3:"uid";s:1:"1";s:6:"status";i:1;s:9:"timestamp";i:1264435921;s:3:"fid";s:2:"51";}}

Any way to clean that up?
I guess I could lock the folder it uploads to down by only giving the admin read and write permisions right?

quicksketch’s picture

Version: 6.x-2.8 »

Moving to 3.x since no new features are being added to 2.x. A note that in 3.x, there is now a public API for providing components, meaning this could possibly be an add-on module to Webform rather than being bundled in it, though either way it'll need updating for the new APIs.

scott m. sanders’s picture

Version: » 6.x-3.x-dev

Subscribing.

scott m. sanders’s picture

Does this work for 3.x, because I do not see a new "multifile" type on my form's components page nor Webform config after adding those two files to modules/webform/components..?

quicksketch’s picture

Any components that were written for 2.x will not work with 3.x, as we've had some pretty major API changes.

attiks’s picture

#1: works great, only problem is the link to the file because the language is added in front of the URL
quick fix, line 538

        $form_item['#suffix'] .= ' ' . l($filedata->filename, $filedata->filepath, array('language' => ''));
kritro’s picture

Cant get this working with Drupal 6.19 and webform 6.x.3.2
Anyone know how?

mireia’s picture

Hi!

I downloaded the file you mention (multifile.zip) and extracted to /modules/webform/components directory but I cannot see the multifile option in the listbox type in a webform.
I don't know what it is wrong. I hope you could help me because I am getting crazy with this.
Thanks,

derp’s picture

subscribe :)
limited results here. It appears i can add files, but they do not get saved on the server. in order to add the new multifile type i added:

    'multifile' => array(
      'label' => t('MultiFile'),
      'description' => t('Allow users to upload multiple files of configurable types.'),
      'features' => array(
        'conditional' => FALSE,
        'attachment' => TRUE,
      ),
      'file' => 'components/multifile.inc',
    ),

to the webform.module file.

any clue on how to make sure files are saved?

sulecki’s picture

i added a files and paste codes to webform.module but it doesn't attach files... is there anybody who know how to save submitted files?

ravi_os’s picture

Priority: Minor » Critical

Really Excellant work Christian Bläul (Gogowitsch), never seen sofar for past 3weeks. looking for same kind of functionality.
i tried with the source provided,i m using 6.20. files are not getting uploaded.

i m trying to create a webform in which some fields like fieldset/textfield. I want to provide a provision with "+Add another" button to users to add rather than limited fields.

could anybody guide me in this.

Thanks in advance.

quicksketch’s picture

Priority: Critical » Normal

Let's keep the priority at what the priority is for Webform as a whole, not for what you need on an individual site. This is still a low priority overall and unlikely to be included any time soon.

favosys’s picture

I would say this is extremely important and needed. I added 4 file uploads to my form but only one shows up? WTH?

aanjaneyam’s picture

will it work in D7 with webform-7.x-3.x.

joshfromdallas’s picture

Looks like there is still a need for this :)

I am working on a few new sites one of them is D6 and the other is D7 and of course i need mutliple file upload functionality. So I remember this issue from before and get back to this page and find out we are back at the drawing board. Sounds like fun! I am going to attempt to figure out what needs to be changed to get it to work with the new version of webform and D7. Any body that can offer any help, it is greatly appreciated!

Thanks to Quicksketch, I will start with the API. Talk to you all soon I hope!

joshfromdallas’s picture

So it looks like a compnent has to be added with the Hook in the API; so I am guessing that is step 1: so I came up with this code

/* Multifile Webform Component */
 function hook_webform_multifile_info() {
 $components = array();

 $components['multifile'] = array(
 'label' => t('Multifile'),
'description' => t('Multifile Support For Webform File Uploads.'),
'features' => array(
 // Add content to CSV downloads. Defaults to TRUE.
 'csv' => TRUE,
 // Show this field in e-mailed submissions. Defaults to TRUE.
 'email' => TRUE,
 // Allow this field to be used as an e-mail FROM or TO address. Defaults
 // to FALSE.
 'email_address' => FALSE,
 // Allow this field to be used as an e-mail SUBJECT or FROM name. Defaults
 // to FALSE.
 'email_name' => TRUE,
 // This field may be toggled as required or not. Defaults to TRUE.
 'required' => TRUE,
 // If this field can be used as a conditional SOURCE. All fields may
 // always be displayed conditionally, regardless of this setting.
 // Defaults to TRUE.
 'conditional' => TRUE,
 // If this field allows other fields to be grouped within it (like a
 // fieldset or tabs). Defaults to FALSE.
 'group' => FALSE,
 // If this field saves a file that can be used as an e-mail attachment.
 // Defaults to FALSE.
 'attachment' => TRUE,
 ),
 'file' => 'components/multifile.inc',
 );

 return $components;
 }

I put it in the module in webform_hooks.php, probably not the right place, I should put it in my template.php right? Anyone have any expireance and guidience for me?

hadsie’s picture

I needed this for a project, so I've implemented an initial module to handle the multifile uploads here: http://drupal.org/sandbox/hadsie/1143186. It's still very untested but I plan to promote it to a full project in the next little while.

I essentially copied the file component from the webform module and then made it work in a very similar fashion to the original multifile component from comment #1. It seems to be working relatively nicely for me so far.

I also had old webform submissions that used the multifile component from #1 so I've written some code to convert the data from the 2.x multifile to this multifile field. It can be run at the path /webform_multifile_convert_data but be careful as it could still destroy your data :).

Cheers,
- Scott

joshfromdallas’s picture

Cool, Thanks Scott! I will test it out!

ksweet’s picture

hadsie, you are a life saver! I'm using your module now and it seems to be working great. Thank you very much! I think you should definitely put this on the main d.o module lists as it's extremely helpful (and most people don't know how to checkout git projects)!

ravaka’s picture

Hadsie, you can probably save my life, i downloaded you module, but I can't get work. I have these errors:

warning: preg_match() expects parameter 2 to be string, array given in /var/www/html/dev/devaux/sites/all/modules/transliteration/transliteration.inc on line 32.
warning: Invalid argument supplied for foreach() in /var/www/html/dev/devaux/sites/all/modules/webform_multifile/multifile.inc on line 472.
warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/html/dev/devaux/sites/all/modules/webform_multifile/multifile.inc on line 730.
warning: Invalid argument supplied for foreach() in /var/www/html/dev/devaux/sites/all/modules/webform_multifile/multifile.inc on line 730.
warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /var/www/html/dev/devaux/includes/database.mysqli.inc on line 323.
warning: Invalid argument supplied for foreach() in /var/www/html/dev/devaux/sites/all/modules/webform_multifile/multifile.inc on line 566.
warning: Invalid argument supplied for foreach() in /var/www/html/dev/devaux/sites/all/modules/webform_multifile/multifile.inc on line 566.

Did you have the same errors ksweet ?
Please help :)
Thanks in advance

doublejosh’s picture

A bit of a late comer on this one, but might I suggest moving from a webform to creating a node with multiple file upload and giving permission to anonymous users?

... this it probably a suggestion for others looking at the thread later.

ravaka’s picture

I found that the transliteration module make this module to works :). Thank you very much anyway

phelix’s picture

Version: 6.x-2.8 » 6.x-3.x-dev
Priority: Minor » Normal

I have this working properly. well at least the option shows up and the selecting of files and everything is working. But it will not save the files to disk. Or display them in the emails that are received or when viewing the results of the form. Is there something that I am missing here?

newgen’s picture

is there a way to get a download of the module, I do not know how to get it out of a git project?
thanks
I really need this type of functionality for web form in ver 3, and drupal 6

daniel

joshfromdallas’s picture

I am haing the same issue, How do you git it?

I donwload git for windows and tried the clone but it is giving me errors saying it is not a repository and stuff?

Anyone have a clue for me?

joshfromdallas’s picture

I get this:

'git.drupal.org/sandbox/hadsie/1143186.git webform_multifile' does not appear to be a git repository

joshfromdallas’s picture

NM -

Me thinks I figured it out!!!!

So step 1: Downlaod the Git prog from here: http://git-scm.com/download I use windows and downloaded the msysGit

Step 2 Install it, note you may want to be sure to check the GUI thing, the rest of it I just guessed on and installed.

Step 3 use that prog to clone to a folder on your drive, in the clone box use git://git.drupal.org/sandbox/hadsie/1143186.git

Note: make sure there are no spaces and crap otherwise it will bomb out.

It should then connect and add the files to your local folder. Looks like Hadsie made a module for us, super cool, I am testing now! :)

joshfromdallas’s picture

I used Hadsie on Drupal 6.22 and webform 3 and all works as advertised! Thanks!

joshfromdallas’s picture

A quick bug list for the MultiUpload fix above:

- Sometimes the file field doesn't show on the email submission
- When it list the file on the email submission it has a

hadsie’s picture

Hey Guys,

I'm not using the webform module for the project anymore which is why I've not grown the multiupload plugin at all. If someone wants to take it on into a full project please do so.

Cheers,
Scott

Anonymous’s picture

Drupal 7 port and patches for webform multifile upload are in this issue here (still off of hadsie's sandbox...)

--> http://drupal.org/node/1225200

attiks’s picture

FYI: I created a full project for this, if any one wants to help feel free: http://drupal.org/project/webform_multifile

attiks’s picture

Title: Multiple File Upload » Multiple File Upload - send as attachment
Category: feature » bug

For the moment there's no way to send the attachment by email, since the code used to attach the file assumes a a $fid as parameter, which we don't have (we have an serialized array)

        if ($email['attachments']) {
          webform_component_include('file');
          foreach ($node->webform['components'] as $component) {
            if (webform_component_feature($component['type'], 'attachment') && !empty($submission->data[$component['cid']]['value'][0])) {
              $file = webform_get_file($submission->data[$component['cid']]['value'][0]); // <== Doesn't work
              if ($file) {
                $attachments[] = $file;
              }
            }
          }
        }
<

I'll try to fix it

attiks’s picture

Status: Active » Needs review
StatusFileSize
new1.41 KB

I added a new 'hook' _webform_get_files_component, is the hook doesn't exists the old method is used.

quicksketch’s picture

Category: bug » feature
Status: Needs review » Active

Could you open a new issue for this patch? It's not a bug as Webform doesn't advertise providing this ability, though it's clearly a limitation that it has special handling for the file component.

jelle_s’s picture

attiks’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.