An upload/attachement field would be a great new feature :-)
Or is there already I way for users to add an attachment in the form ? (I couldn't find it)
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | file.inc.txt | 14.72 KB | quicksketch |
An upload/attachement field would be a great new feature :-)
Or is there already I way for users to add an attachment in the form ? (I couldn't find it)
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | file.inc.txt | 14.72 KB | quicksketch |
Comments
Comment #1
quicksketchThere is currently no way for a user to upload a file. We're working on making file uploads (along with other potential field types) easier to implement, similar to the flexinode module. I've posted similar information in this forum topic: http://drupal.org/node/59050.
Comment #2
kingofsevens commentedHow about this? I read the forum topic and an idea pop'ed into my mind. You may already thought of this before. Here it is... oh btw I second the file upload field. =)
Why not use the upload module for this and keep the files in the folder files/webform/title/ (also can be files/title) then you can rename the file to submission_number.ext and keep only the path in the webform table. Then the module can email a text only mail and add the whole path to the mail for the admin to download.
Also when downloading csv. Drupal will zip the folder files/webform/title/ on the fly with csv.
And if you ever add the multipart email support you can make this as an option. What do you think? =)
Comment #3
quicksketchInteresting idea, but I'm not sure if that kind of integration is possible. The upload module is made explicitely to upload files attached to nodes (ie. by clicking the 'edit' tab of the node). Webform should allow many files to be uploaded by anyone with 'view' priviledges and store them along with the submissions.
I'm glad you posted though, since you answered some of my questions I had meant to post a few days ago. I'll outline these questions in the next post.
Comment #4
quicksketchI've attached a demo file.inc component that I encourage all interested individuals in trying out. This module will only work with the last few builds of the CVS version of webform.
Some particular options I'd like to consider in terms of file handling include:
I believe those most important considerations that I have yet to implement. I'm also open to suggestion as to how file filtering could be improved (you'll see what I've done so far in the attached module), both functionally and aesthetically.
Comment #5
kingofsevens commentedI have uploaded the module to my website and I tried it. I have added lots of fields.. but denied with several errors of different fields.
user warning: Unknown column 'pid' in 'field list' query: INSERT INTO webform_component (nid, cid, pid, name, type, value, extra, mandatory, weight) VALUES ...I'll will try again.. and tell you later..
Oh, I also added a RTF extension after PDF. I think that should be made available.
Comment #6
kingofsevens commentedNope, nothing has changed... I'm using Drupal 4.7.2 with webform cvs with the file.inc. But there seems to be an error. I have tried with and w/o the file field. Here is the whole error message it says there is an error in the drupal database includes.
or is it my problem?
Comment #7
BachusII commentedUploaded as in "I did not have webform installed previously but now I do." or uploaded as in "I used to have webform installed, and now I have a newer version."?
If the lather, you might have forgotten to visit the http://yoursite.com/update.php page. The database tables have changed, and your errormessages suggest to me the tables were not yet updated.
Comment #8
haykelbj commentedHi,
I tested the file upload component with the latest cvs version of webform (27.07.2006). I can add a file field, but when I submit the form I always get the error:
"file field name" field is required.even though I selected a file with the file browser. Looking at the HTML source of the page, I noticed that all other fields have the names
edit[submitted]["field name"]and the ids
edit-submitted-"field name"while the file field has the name
edit["field name"]and the id
edit-"field name"(the submitted-keyword is missing). Could this be a hint for the problem?
Another thing: It would be nice if information about the allowed max file size and extensions is added to the description of the file field.
Comment #9
haykelbj commentedSome other comments about the file field when it's not mandatory:
Files with the '' extension are not allowed, please upload a file with a gif, jpg, png, doc, or pdf extension.The extensions are ok, they are the ones I selected when I added the fieldHope this helps.
Comment #10
haykelbj commentedIt's me again ;)
* The 'field requiered' problem seems to be a bug in drupal (see my bug report http://drupal.org/node/76162). One workaround would be to always set the
#requiredfield for files tofalseand pass$component['mandatory']to the_webform_validate_file()function and use it to test if the file have been submitted. The only problem is that the fields will not be marked as required (red *).* The extensions problem comes from the fact that in the
_webform_validate_file()function, no test is done to see if no file was submitted. Using the same workaround as above, we would be able to test for this situation.Here are the needed changes (only the lines that need to be changed!):
* Function
_webform_render_file ($component):old:
'#required' => $component['mandatory'],new:
'#required' => false,old:
'#validate' => array('_webform_validate_file' => array($component['name'],$component['extra']['filtering'])),new:
'#validate' => array('_webform_validate_file' => array($component['name'],$component['extra']['filtering'],$component['mandatory'])),* Function
_webform_validate_file ($component):old:
function _webform_validate_file ($formelement,$fieldname,$filters) {new:
Comment #11
quicksketchThere are still several critical areas of code that have not yet been written for the file component. I'm mostly looking for suggestions at this point, not testing or bug-reports. I also forgot to mention the running update.php is necessary, as BachusII pointed out. Please make sure you backup your database before installing this new component, since it is still under development and further schema changes may be necessary.
Comment #12
BachusII commentedThe attachment module (http://drupal.org/node/10245) might yield some interesting ideas.
Comment #13
kingofsevens commentedOkay, you were right BachusII, I didn't run the update.php. Now I did and it works fine with few problems. I know you don't want bug reports quicksketch, but here is a few I found you can check it before you start debugging. And if you ask me it is almost ready to release. The way it works is just fine. What do you guys think?
- After you create a file field and return for editing it. When the page is displayed the web images in the upload filtering part are all selected even though they weren't when the field was saved.
- The uploading directory works as long as it is "files". When you change it to "files/something" or "files/something/" it uploads the file to the a file named "something" in the "files" folder. And also it displayes the file name in the table view to "something" which is expected. When you upload the same file twice it names the other one to "something_0" with the same display name of "something" which is also expected but it may be better if it displayes "something_0". Well, this last part may not be related to the webform module but to drupal itself.
- Also, sorry for writing this here. Now the downloaded file bares the extension ".csv.txt". Shouldn't it be ".csv" only?
--- Oh, a zip for downloading the file would be nice.
Comment #14
rose commentedWhere I have to put "file.inc.txt"?
Comment #15
quicksketchjack in box: See http://drupal.org/node/76154 for why .txt is added. This affects all uploaded files in Drupal. Thanks for the note on changing the upload directory.
rose: Remove the '.txt' from the file and drop it in 'modules/webform/components'. There should be several other files with '.inc' extensions there.
Comment #16
rose commentedThank you so much . I got this error when i creat file attached field."warning: htmlspecialchars() expects parameter 1 to be string, array given in C:\AppServ\www\tongjitest\includes\bootstrap.inc on line 599. " what should I do?
Comment #17
rose commentedSorry. it is working now after replacing 4.7 version with cvs version of webform. Thank and appreciated.
Comment #18
kingofsevens commented@quicksketch: Have you seen this module? MimeModule, I have discovered it today. May be this can help but I really don't think it is necessary if you provide the url in the mail. BTW, url is not displayed in the mail just the name of the file.
Comment #19
quicksketchJack in the box: Thanks for the link. That's really cool. Maybe I'll put something in the default theme which includes an option for HTML mail if MIMEmail exists. After looking at this module, I agree we shouldn't include the image as an attachment. Maybe provide it as an option, I'm sure someone will request it eventually if I don't put it in initially.
Comment #20
quicksketchThis component has now been commited to CVS.
Comment #21
quicksketchComment #22
unmesh20 commentedi am working on school web site
i need to create the staff details
i create the fields through web Forms and upload the file as a staff image
but in reports it shows as a attachment , insteas i wants to show image directly
Please helped me out
i am news to the Drupal
Please write me the solution to following e mail
unmesh.sonawane@gmail.com
Comment #23
quicksketchPlease open a new issue for this request.