The files uploaded were lost, because $_FILES['files']['name']['mykey'] was NULL

CommentFileSizeAuthor
#1 1145490-fix.patch3.18 KBattiks

Comments

attiks’s picture

Status: Active » Needs review
StatusFileSize
new3.18 KB

Patch attached that uses orig_name if name isn't used

fix for file structure
extra check for theme_webform_display_multifile

cyborg_572’s picture

Thanks, this seems to work for me.

attiks’s picture

Status: Needs review » Reviewed & tested by the community

changing status

cyborg_572’s picture

Status: Reviewed & tested by the community » Needs work

It seems I spoke too soon. After patching the transliteration module to support this kind of file array uploading (#1243974: Supporting Files uploaded as an array), the transliteration errors went away and made room for this patch to cause some errors of it's own,.

So basically, removing or repairing Transliteration makes the files upload properly without this patch. If transliteration is present and causing problems, this patch seems to work around them, but without transliteration's errors, this patch just prevents the files from uploading. (specifically, I get this: Warning: basename() expects parameter 1 to be string, array given in file_save_upload() (line 615 of includes/file.inc). and this:
For security reasons, your upload has been renamed to ..

attiks’s picture

Project: Webform Multifile » Webform Multiple File Upload
Assigned: Unassigned » jelle_s
cyborg_572’s picture

Version: » 6.x-1.0

I noticed in the commit logs that you plan to apply this patch. I'm just wondering if you've tried the 6.x-3.x version of Transliteration which seems to fix it from that end? This patch actually causes some conflicts with that one. So either this issue is fixed and the solution is to use Transliteration 6.x-3.x, or the patch is also fixing some other edge case, and needs to take the changes in the transliteration module into account before being applied.

attiks’s picture

Assigned: jelle_s » attiks

I tried the 6.x-3.x but nothing is working for the moment, or the files aren't listed on the submission, or they are listed as array.

attiks’s picture

Status: Needs work » Fixed

I combined both patches and fixed some typos, it should be OK for transliteration 6.x-3.x branch

Issue #1145490 by attiks: Fixed Files are not saved.
Issue #1246794 by cyborg_572: Added Multiple multifile fields, and scripts in the footer.

Status: Fixed » Closed (fixed)

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

flirpkrahusel’s picture

I just installed the version 6.x-1.1. After submitting a form with a multifile and one or more files attached, I get this warning:

warning: basename() expects parameter 1 to be string, array given in /www/htdocs/[.........]/includes/file.inc on line 577.

... which is the marked line:

// Begin building file object.
$file = new stdClass();
$file->filename = file_munge_filename(trim(basename($_FILES['files']['name'][$source]), '.'), $extensions);
$file->filepath = $_FILES['files']['tmp_name'][$source];
$file->filemime = file_get_mimetype($file->filename);

Additionally I get the message, that for security reasons the uploaded file has been renamed ("Aus Sicherheitsgründen wurde die hochgeladene Datei in . umbenannt.")

I am using webform 6.x-3.14. Tried the dev version of webform_multifile (6.x-1.x-dev) too, with same results.

Any idea?

attiks’s picture

Status: Closed (fixed) » Active

@flirpkrahusel can you try with the transliteration module installed?

flirpkrahusel’s picture

Hi attiks,

------------
EDIT: Forget about my post further down here. Multifile works perfectly using the dev-version of transliteration.

Thank you for this great module!
------------

thanks for your hint. It works better now: the files are uploaded an everything is fine, but after submitting, the following warnings are shown:

warning: preg_match() expects parameter 2 to be string, array given in /www/htdocs/[.........]/sites/all/modules/transliteration/transliteration.inc on line 32.
warning: Invalid argument supplied for foreach() in /www/htdocs/[.........]/sites/all/modules/webform_multifile/multifile.inc on line 477.

Below I marked the mentioned lines.

transliteration.inc on line 32:

function transliteration_process($string, $unknown = '?', $source_langcode = NULL) {
// ASCII is always valid NFC! If we're only ever given plain ASCII, we can
// avoid the overhead of initializing the decomposition tables by skipping
// out early.
if (!preg_match('/[\x80-\xff]/', $string)) {
return $string;
}

multifile.inc on line 477:

// Build a human readable list of extensions:
$extensions = $component['extra']['filtering']['types'];
$extension_list = '';
if (count($extensions) > 1) {
for ($n = 0; $n < count($extensions) - 1; $n++) {
$extension_list .= $extensions[$n] . ', ';
}
$extension_list .= 'or ' . $extensions[count($extensions) - 1];
}
elseif (!empty($extensions)) {
$extension_list = $extensions[0];
}

if (in_array('jpg', $extensions)) {
$extensions[] = 'jpeg';
}

foreach ($_FILES['files']['name'][$form_key] as $key => $filename) {

$dot = strrpos($filename, '.');
$extension = drupal_strtolower(drupal_substr($filename, $dot + 1));
$file_error = FALSE;
if (!empty($extensions) && !in_array($extension, $extensions)) {
form_error($element, t("Files with the '%ext' extension are not allowed, please upload a file with a %exts extension.", array('%ext' => $extension, '%exts' => $extension_list)));
$file_error = TRUE;
}

jelle_s’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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