I've added the file component to accept .pdf and .doc file formats for resumes, this is a required field as part of a Career form.

When the form is filled out and submitted I get an error saying that the attache resume field is 'required' when I did browse for a file to upload.

The file is clearly not attaching, any help is greatly appreciated.

CommentFileSizeAuthor
#10 file.txt18.1 KBGentoo7
#6 _webforms_patch.txt1.06 KBlaxis
#1 diff.txt2.12 KBmkalbere

Comments

mkalbere’s picture

StatusFileSize
new2.12 KB

Got the same problem when file is required. I succeed to make it work with the following changes.
Everythings seems to be ok, but I've no idea if this change is clever ;-)

mzabala’s picture

Also, when I use a file attachment field, if I try to add another field after that, it takes me to a 404 "page not found" error page. However, the URL that pulls up is.

http://www.[mydomain].com/node/[nodenumber]/edit

if I simply go up to the address bar and hit enter and go to the same url, the webform edit page reappears instead of giving me the page not found error previously mentioned.

Also, it seems impossible to add two file attachment fields. In fact, trying to add two not only sends me to page not found, but it seems to remove my first one.

eer’s picture

Component: Code » Miscellaneous

Same problem here. A few more observations:

It's impossible to edit a file field after it's created.
It's impossible to add a second file field.
File is not being uploaded when it's either required or not required. (And produces an error message when it's required.)

Gentoo7’s picture

I am coming across this problem. There is no link in the email and if i browse at the location where these files should reside there no files there either.

Gentoo7’s picture

Does anyone know how to fix this issue, so we can attach files?

thanks

laxis’s picture

StatusFileSize
new1.06 KB

With this patch the file uploading is work.

mkalbere’s picture

You forgot to patch a part of the file cf patch#1 bellow. I don't think it's usefull to post twice the same changes ;-)

Gentoo7’s picture

after the changes from the patch the files download great!!!
but is there anyway to receive a link within the email for the location of the file.

thanks a lot!!!

eer’s picture

The patch(es) do not seem to work for file fields which are not mandatory. Still same problem: cannot add more than one field and other problems as well.

Gentoo7’s picture

StatusFileSize
new18.1 KB

hey eer,

I'm no programmer but this are how i fixed my file.inc (i just changed to the patch that laxis posted) and it works for me, maybe try to replace your file.inc by copy and paste this
code. the file.inc file is located under components folder. The only problem is that when you receive the form email THERE ARE NO LINKS to the
uploaded files, so for now i have to manually go and search for the uploaded file, which becomes very confusing if you have a lot
of files being uploaded.

Here is my file.inc :

rba’s picture

Category: support » bug
Priority: Normal » Critical
Status: Active » Needs review

mkalbere's patch ( http://drupal.org/files/issues/diff_8.txt ) does the job, whether or not the field is mandatory.

laxis, your patch does NOT work in every situation : it only fixes the behavior of the "_webform_submit_file" function while you also need to fix how "_webform_validate_file" and "_webform_required_file" functions access the uploaded file in the $_FILES array ... which mkalbere's patch does.

The three functions try to access the uploaded file in the $_FILES['files']['name'][ $component['cid'] ] - where $component['cid'] is the internal component id, eg: "1198777242" - where actually, the uploaded file info will be stored in $_FILES['files']['name'][ $component['form_key'] ].
$component['form_key'] is whatever you typed as the "Field Key" when you added the "file" component field to the form.
( Actually, since "Field Key" is initially valued to the $cid, you won't see the problem if you don't change its value ).

mkalbere's patch is not perfect, because he used a shortcut : since "_webform_validate_file" and "_webform_required_file" have $cid as an argument and that $cid ( == $component['cid'] ) is used numerous times where a $form_key ( == $component['form_key'] ) should be used, he simply changed the $cid value to the $form_key value in the function "calls" ( lists of the two functions arguments in the "_webform_render_file" function ).
Hence, he did not have to modify "_webform_validate_file" and "_webform_required_file" function definitions nor code.
But it *might* lead in some confusion in the future, so I'd let the module maintainers decide how to integrate it in the trunk.

eer> roll back your modifications on the code of the module (getting a fresh copy of the source code from here, for instance) and then apply mkalbere's patch.
Gentoo7> you should do the same as Iaxis' patch, unfortunately, is not covering all use cases.

quicksketch’s picture

Thanks, I applied mkalbere's patch and it correct the problem with the file not saving. The file does not yet show up in the email.

quicksketch’s picture

Status: Needs review » Fixed

I shuffled around the processing of file components so that the file URL is properly sent in webform email. Thanks everyone!

eer’s picture

Status: Fixed » Active

Sorry for opening the issue again but it's not fixed here what a pity.

I have just uploaded the latest preview version (January 19, 2008) of the plugin. I have created a new webform. Then I added a file field successfully. Then I tried to add another file field and get back nothing, the system tried to process the request and I finally got a blank page. When I again go to the Edit page, I only see the previously added file field and not the new one I tried to add. BTW, both fields were non-mandatory.

Any suggestions?

Thanks.

eer’s picture

Well, this has been fixed after I upgraded my PHP version from 4.x to 5.x in my GoDaddy account.

quicksketch’s picture

Status: Active » Fixed

Excellent. Since PHP4 is officially unsupported, I'll close back up.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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