I've seen some issues related to this already but the one has been closed (fixed by user) and the other is related to pagebreak so neither apply to this case. I recently upgraded to the latest release of webform and file uploads are not working. The form in question contains multiple file upload fields all pointing to the same directory. These fields all have the same parent fieldset, and there is no pagebreak. Form submits as expected but files are not put in the directory. Let me know if you need any additional information.

Comments

sander-martijn’s picture

Version: 5.x-1.8 » 5.x-1.9

originally filed under 5.x-1.8, I downgraded to 5.x-1.4 temporarily to fix it, but then emails were coming through blank. I just saw the new release so I tried that, but file uploads are still broken in this release so I am primarily posting to update the version to 5.x-1.9. Not sure if emails and other issues are working again, waiting on client feedback. Is there a version I can try where both of these work until the issues get hammered out? Or is there a patch posted in one of the other bug postings that i haven't seen that i can try? The client is getting quite upset as they are getting backlogged.

goldoak jp’s picture

Priority: Critical » Normal

Also having this problem.
File does not upload to server.
File name or link is not listed on email.
File name or link does not show on results
Results analysis shows zeros for all stats for file component fields

Thanks for your attention to this.

goldoak jp’s picture

I have now also tried the dev version 2
updated database, re-activated module, deleted old form, and created new.

Still not getting file upload as described earlier.

See form here:
http://dev.lakecountryjournal.com/photo_entry

Thanks

pebosi’s picture

Ok i think we get closer to fix it:

the function "_webform_client_form_submit_process" is not calling "_webform_submit_file" if the file-field is in a fieldset. i will try to create a patch as soon as possible.

regards pebosi

spamjim’s picture

The fieldset matter may only be part of the problem.

I am using a single file upload outside of any fieldset container and am experiencing a different problem (only mentioned in this issue report, assuming that it is related). The file uploads okay and displays okay in but when an admin goes back to edit the record, the path information to the uploaded file is lost.

For example:

Results tab -> Submissions -> Operations -> View
This allows the admin to see the attached file in a record and everything works well.

Results tab -> Submissions -> Operations -> Edit
This allows the admin to see the attached file but once any changes are made to the form, the reference to the uploaded file is lost.

mikgreen’s picture

It seems that check on line 1644 is causing the trouble.

if ($component['parent']) == $parent) {
...

I don't see what is it for actually, it causes everything that is below root level not to be precessed.

After commenting it out however, file uploads still don't work.

The quick fix for me was moving file field in to root level.

quicksketch’s picture

Status: Active » Fixed

Okay, I'm pretty sure I nailed this one down in all versions.

- File components can be inside of fieldsets. I didn't see this problem anywhere in current versions except Drupal 6, 2.x version.
- Submissions can be edited without loosing current uploads.
- New files can be added to submissions while editing.

I'm not seeing any problems with uploads outside of not working with page break components (I think there's a separate issue for that one).

So I'm cautiously going to mark as fixed. Please reopen if any of the above problems still persist in the latest dev versions. I'll release beta 2 of the 2.x version and 1.10 shortly if we don't have any problems.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

dalin’s picture

Status: Closed (fixed) » Active

@quicksketch I just tried 5.1.10 and no go, I then tried 5.2.beta3 and still no go. This form has some text fields, an email field, and a file field. With nothing entered in the file field this is the order that things run in:

[click submit]
webform_client_form
_webform_validate_email
_webform_validate_file
webform_client_form_validate
webform_client_form_submit
[thank you page displayed]

All fine and dandy, that's what we expect.
Try again with invalid data in the file field:

[click submit]
webform_client_form
_webform_validate_email
_webform_validate_file
webform_client_form_validate
[sent back to form with an error for "Files with the 'es' extension are not allowed, please upload a file with a gif, jpg, png, psd, odf, pdf, doc, xls, dmg, or zip extension."]

Still looks good.
But if we try with valid data in the file field:

[click submit]
webform_client_form
[sent to a blank webform]

Whiskey, Tango, FoxTrot! Why did it do that?

dalin’s picture

Status: Active » Closed (fixed)

The problem was actually that I wasn't paying attention to the output of my CVS commands and there was a conflict. Therefore I'm changing this back to being closed.

Golem07’s picture

Status: Closed (fixed) » Active

This is my first bug submission - hope I don't break anything ;).

Anyway. I am still having the very same issue with 5.2 beta 2 and 3. All file fields work perfectly well when in root. But as soon as I move any of them into a fieldset no files are being uploaded or added to the database. I do not use pagebreak in the webform. There seems to be some uploading going on (telling by how long the submission process takes). But no file does actually make it to the server. Since the problem seems toi have been solved a couple of versions before, I am not sure if it might be me who is actually doing something wrong. Any place that I should take a look?

Thanks a lot in advance since the fieldset option would really be very helpful on my site.

amrlima’s picture

I also have this problem.
This is the error message I get when uploading a file:

* warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpRjN4YL' to '' in /home/amrlimai/public_html/main/includes/file.inc on line 572.
* Erro no carregamento do ficheiro. Não foi possível mover o ficheiro.
* The uploaded file was unable to be saved. The destination directory may not be writable.

This is really a show stopper for webform, since file uploads are essencial in a module such as this. I hove it get's fixed soon. I'm using 2.0 beta5

Mac Clemmens’s picture

Yes -- I'm having the exact same error:

* warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php3BRrpg' to '' in /home/dwp/www/www/6.2/includes/file.inc on line 572.
* File upload error. Could not move uploaded file.
* The uploaded file was unable to be saved. The destination directory may not be writable.

My guess is that it has to do with the _webform_submit_file() function:

function _webform_submit_file(&$data, $component) {
  $current_file = unserialize($data);
  $upload_dir = variable_get('file_directory_path', 'files') ."/webform/". $component['extra']['savelocation'];
  if (!empty($_FILES['files']['name'][$component['form_key']])) {
    if (file_check_directory($upload_dir, FILE_CREATE_DIRECTORY)) {
      $file_saved = file_save_upload($component['form_key'], array(), $upload_dir);
      if (!$file_saved) {
        drupal_set_message(t("The uploaded file %filename was unable to be saved. The destination directory may not be writable.", array('%filename' => $file_saved['filename'])), "error");
      }
      else {
        $data = serialize((array)$file_saved);
        file_delete($current_file['filepath']);
      }
    }
    else {
      drupal_set_message(t("The uploaded file was unable to be saved. The destination directory does not exist.", "error"));
    }
  }
}
Mac Clemmens’s picture

Version: 5.x-1.9 » 6.x-2.0-beta6

This problem still exists on the new release. Getting the exact same error. I'll try to look through the code and see what I can figure out.

John Garnett’s picture

I had this same problem using Drupal 6.2 and webform-6.x-2.0-beta6.tar.gz.

I tracked it down to Drupal and Webform having differing ideas about where the file save directory is. Webform thought it was files/webform and Drupal thought it was sites/default/files.

I solved the problem by configuring Drupal to use files as the directory in which to save files. You can change this in Drupal's "Administer -> Site Configuration -> File System -> File System Path" configuration page. I set this field to 'files' instead of 'sites/default/files' or whatever it is.

You may also be able to solve this by changing Webform to use whatever files directory that Drupal is configured to use. I'm not sure how to do this - hopefully, someone will post an answer.

sohopub’s picture

Your edit didn't take the system kept saying now that the file didn't exist. But is interesting is that by reentering the sites/default/files path in the field after that error the Webform module all of a sudden accepted the original default path. So it appears that with this glitch you need to reenter the path for it to take.

Thanks for helping!

agerson’s picture

A Fix!

For people running drupal on unix/linux/mac creating a symlink will fix the problem as well:

1. Open a Terminal window
2. CD to your drupal directory
3. Run this command:

ln -s sites/default/files files

Remember to protect this folder securely in a way that is appropriate for your site.

What is a symlink?

quicksketch’s picture

Status: Active » Fixed

Thanks everyone for the reports. The problem is indeed that Webform is looking in the wrong location to save files. In Drupal 5 the default save location was "files", but in Drupal 6 it is now conf_dir() . '/files'. Webform was still assuming the old default. You can work around the problem simply by going to admin/settings/file-system and saving the page (no changes necessary), this will make Drupal save an actual value in the database rather than using the default (even though the saved value and the default should be the same).

I've committed the below patch to both Drupal 5 and 6 versions of Webform and the fix will be included in the next release of Webform.

Patch: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/webform/com...

GoofyX’s picture

quicksketch, is the patch necessary for the Drupal 5 version?

quicksketch’s picture

No, it's not necessary for Drupal 5 (because Webform uses "files" as the default path, same as D5), but I applied the patch there also because it's the proper way to get the file directory path, rather than assuming a default.

Golem07’s picture

Version: 6.x-2.0-beta6 » 5.x-2.0

I am not sure if the solutions given here are supposed to also fix the problem that I have described in reply #11. I am still unable to upload any file as long as the file field stays within a field set. The corresponding field title won't even show in the submission email. Everything is fine as soon as I move the file field back to root. Then the field title will show in the email as well (empty though when no file has been uploaded).

So in my case it does not seem to be a folder problem per se but with the usage of field sets.

A solution or hint would really be great.

quicksketch’s picture

Golem07, if you can move that particular request to another issue, that'd be appreciated. In theory, each issue fixes a single bug, which it looks like yours is separate from the one fixed in this thread.

I think your issue might actually be related to this other issue: #262154: Empty file upload w/fieldsets

Golem07’s picture

Thank you very much for pointing me to that other issue. This actually solved my problem and helped me a lot! :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

fmfabila’s picture

Version: 5.x-2.0 » 6.x-2.1
Status: Closed (fixed) » Active
quicksketch’s picture

Status: Active » Closed (fixed)

fmabila: If you're experiencing this issue under different circumstances than the ones described, please open a new issue. We've already fixed 2 bugs in this thread, it'd be better if we could create a new thread to address any new problems with the file upload.

ajay1kumar1’s picture

I solved the problem by configuring Drupal to use files as the directory in which to save files.
You can see this in Drupal's "Administer -> Site Configuration -> File System -> File System Path" configuration page.
you can see like this "sites/default/files"

Run this commnad
sudo chmod 777 /PATH_TO_YOUR_ROOT/sites/default/files
&
sudo chmod 777 /PATH_TO_YOUR_ROOT/sites/default/files/* (optional)

I think this will help someone.
Thanks
Ajay singh rathore
Tech lead.
Cyberinfrastructure, Indore, India

vindesh’s picture

Please Try This

sudo chmod -R 777 /PATH_TO_YOUR_ROOT/sites/default/files

I think this will help someone.
Thanks
Vindesh Mohariya
Team lead.
Cyberinfrastructure, Indore, India

canogueira’s picture

Don't do a 777 to your directories.

That's a really bad idea. Googleit javascript hack 777

I can't put any files to my webform (755) directory, but i thin'k that's a server command permition problem.

I'll post the solution as soon I find it.