Welcome, Guest. Please login or register.
Did you miss your activation email?
February 12, 2012, 11:24:53 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
149698 Posts in 21103 Topics by 7538 Members
Latest Member: ionline
* Home Help Search Login Register
Pages: [1] 2 3 ... 8   Go Down
Print
Author Topic: FormX - Forms with file captcha/upload/calendar/mail attachment/submission  (Read 32166 times)
sharmpro

Offline Offline

Posts: 64



WWW
« on: June 13, 2008, 02:02:13 AM »

Hi,
I needed to upload a file and attach it to an email. Here is where everything started....

Got some ideas from existing modules and snippet and now I'd like some feedback.

- NEW VERSION 2.4.8 -

In the project pipeline:
* Sent mail to recipient based on user selections (opt1 -> email1@yourdomain.com, opt2 -> email2...)
* Select field with default option amd display of another string than the value itself

Known issues:
* CSS definition for checkbox and radio fields still to complete


- Some code optimization
- Captcha got * of required
- .CSS cleanup and fixes
- Fix 'not saving field' if new installation

- Help w/tooltip on each form field
- Folder /media wrong chmod
- Drag+Dop for Filed order definition
- Order of filelds now can be done with Drag&Drop
- New .css definition for frontend BE CAREFULL IF YOU ALREADY USED ONE!
- Started Help page
- Cleaned up Backend and use of Template
- Resolve some security issue
- Now uses jsCalendar from standard WB distribution
- Removed from backend unused _html fields
- Fixed Bug - Securty issues - Sanitized some params
- Fixed bug - Install error
- Fixed bug - Multiple file upload
- Fixed bug - Submissions not stored in database
- Fixed Max file size bug (was not saved) Thanks to Aldus.
- Submission data saved into serialized db field
- File Upload Required works!
- File Upload chmod (0666 for direct link)
- File uploaded linked in submission (backend)
- Added Select email_from as name <address>
- Added File Type to Upload (jpg,tif,png,pdf,....)
- Automatic creation of upload folder
- Bug fix file view.php - $err
- Added file attachments
- Added Date field
- Added File Upload
- Added File Attach to email


Features:
Field filename
   - PEAR File Uploader
   - File Upload chmod (0666 for direct link)
   - File uploaded linked in submission (backend)
   - Automatic creation of upload folder
   - Added Select email_from as name <address>
   - Added File Type to Upload (jpg,tif,png,pdf,....)
   - MAXFILESIZE defined in settings.
   - folder (from /media) to store file
   - if attach file to email
Field date
   - date format

Form submission:
  - return to page#section

After submission the form return to the same page#session in order to show the user the same section he submitted from.

Please fell free to suggest and  integrate, will be nice (one day) to have a solid and complete 'form' module with all the feature we think it should have...


Stefano
« Last Edit: October 24, 2008, 11:31:56 PM by sharmpro » Logged

Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4755



« Reply #1 on: September 04, 2008, 10:49:16 AM »

Hello Stefano,

I try to implement your Module, but I get a problem again and again.

Notice: Use of undefined constant err assumed 'err' in /mnt/web4/12/33/52843xx/htdocs/xxffxx/modules/formx/view.php on line 137

I looked into the view.php but I don't seem to find the cause of the problem.

Anyway, the e-mai is comming to the specified e-mail address but without the file "Upload faild" is what I get.

Do you have any suggestions?

Best Regards,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
aldus

Offline Offline

Posts: 1238


« Reply #2 on: September 04, 2008, 12:16:47 PM »

Hello Stefek

There is a missing "$" in the line before the "err", so the correct line should be like
Code:
<?php
/**
 *    @version 0.1.1
 */
 
echo "<br><b>There was an error uploading the file: ".$_FILES['field'.$fileid]['error']." ".$err.", please try again!<b><br>";
?>


Regards
Aldus
Logged
sharmpro

Offline Offline

Posts: 64



WWW
« Reply #3 on: September 04, 2008, 12:52:12 PM »

Hi,
sorry for the bug I forgot into the module.
Yes the $err is the problem.

I repacked the file v1.1b with the fix.

Regards

Stefano
« Last Edit: September 04, 2008, 01:24:40 PM by sharmpro » Logged

Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4755



« Reply #4 on: September 04, 2008, 12:59:48 PM »

Hello!

Thank you Aldus.
This fixed the problem.

But I still have a upload proplem.
The massage goes like this:
There was an error uploading the file: 2 UPLOAD_ERR_FORM_SIZ E, please try again!

Any suggestion on this issue, Stefano?


Best Regards,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
sharmpro

Offline Offline

Posts: 64



WWW
« Reply #5 on: September 04, 2008, 01:19:54 PM »

Hi,
did you specified "Max upload file size Kb: 1024"? Unfortunatelly the module wrongly consider "bytes" not "Kb"..

Try once to specify this value in bytes.

Already fixed in Ver 1.1.c

Regards,
Stefano
« Last Edit: September 04, 2008, 01:24:00 PM by sharmpro » Logged

Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4755



« Reply #6 on: September 04, 2008, 01:45:41 PM »

did you specified "Max upload file size Kb: 1024"? Unfortunatelly the module wrongly consider "bytes" not "Kb"..

All right.
I specified the byte size to 999999. So this should be enough.

But another NOTE appears. It goes like this:
Code:
Warning: move_uploaded_file(/mnt/web4/12/33/---/mnt/web4/12/33/5284333/htdocs/aschaffenburg/res/bewerbungsfotos/04092008020955-logo.jpg)
 [function.move-uploaded-file]: failed to open stream: No such file or directory in
mnt/web4/12/33/---/modules/formx/view.php on line 118

Warning: move_uploaded_file() [function.move-uploaded-file]:
Unable to move '/mnt/shared/tmp/phpRxaiyV' to '/mnt/web4/12/33---/mnt/web4/12/33/5284333/htdocs/aschaffenburg/res/bewerbungsfotos/04092008020955-logo.jpg'

 in /mnt/web4/12/33/---/modules/formx/view.php on line 118


There was an error uploading the file: 0 MOVING_FILE, please try again!

That's pretty strange to me   huh

Regards,
Stefek

BTW: After I get this running, this will be my preffered form module. I think file attachement should be standard.
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
erpe

Offline Offline

Posts: 2077


WWW
« Reply #7 on: September 04, 2008, 02:07:48 PM »

Hi

unfortunately I have to confirm: I get the same error.

rgds

erpe
Logged

sharmpro

Offline Offline

Posts: 64



WWW
« Reply #8 on: September 04, 2008, 02:19:48 PM »

Hi,
is the "Upload Files Folder:" MUST starting with /media/your_folder/
The  /media/your_folder/ must be created manually.
Stefano
Logged

Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4755



« Reply #9 on: September 04, 2008, 02:47:43 PM »

Hi,
is the "Upload Files Folder:" MUST starting with /media/your_folder/
The  /media/your_folder/ must be created manually.
Stefano

Hello Stefano.

My current "media" folder has the name "res".

Now I createda second folder "media" and set the permission to 777. (for testing)

Unfortunately it dosen't work for me.
I get the same Note as before.

What could fix the problemo?

Best Regars,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
aldus

Offline Offline

Posts: 1238


« Reply #10 on: September 04, 2008, 03:04:19 PM »

Reading the errormessage form Stefek carefully, i regonize a missing "/" slash in the pathnames:

Code:
/mnt/web4/12/33---/

and
Code:
/mnt/web4/12/33/---/

As this comes up at the begin of the pathnames i asumee it have to do with WB_PATH ...
as the "htdocs"-folder comes some subfolders later. Could be a server-admin typo ...

Edit I also remember a client with php but no permissions to upload files via PHP ... could be also the (web-)package.

Regards
Aldus
« Last Edit: September 04, 2008, 03:07:51 PM by aldus » Logged
erpe

Offline Offline

Posts: 2077


WWW
« Reply #11 on: September 04, 2008, 03:27:43 PM »

Works now.

Set path in options like:
Code:
/media/name/file
(path file created in media) and form loads up your file as (for example):
         file04092008040935-yourfile.txt

But don't ask me why!!

rgds

erpe

Edit: Do not set "slash" after "file" in the path: /media/name/file  !!
« Last Edit: September 04, 2008, 04:09:52 PM by erpe » Logged

Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4755



« Reply #12 on: September 04, 2008, 03:43:07 PM »

Reading the errormessage form Stefek carefully...

Hello Aldus, I just have shorten up the path.
The (my new) error goes like this (I applied Erpe's suggestion):
Warning: move_uploaded_file(/mnt/web4/12/33/5284/htdocs/myfolder/mnt/web4/12/33/5284333/htdocs/aschaffenburg/media/bewerbungsfotos/file04092008040942-dsc_0091-2.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /mnt/web4/12/33/5284/htdocs/myfolder/modules/formx/view.php on line 118

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/mnt/shared/tmp/phpAZaqSg' to '/mnt/web4/12/33/5284/htdocs/myfolder/mnt/web4/12/33/5284333/htdocs/aschaffenburg/media/bewerbungsfotos/file04092008040942-dsc_0091-2.jpg' in /mnt/web4/12/33/5284/htdocs/myfolder/modules/formx/view.php on line 118


Would be great if this could be fixed.

I have another "fork" working (but with some issues).
This one moves the pictuers correctly. The only "bug": it is based on a old version of the Form Module
http://www.websitebaker2.org/forum/index.php/topic,6652.msg41490.html

Never mind wich can be fixed. If someone can help me it would be great!

Best Regards,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4755



« Reply #13 on: September 04, 2008, 04:02:15 PM »

Works now.

Set path in options like: /media/name/file
(path file created in media) and form loads up your file as (for example):
         file04092008040935-yourfile.txt

Works now!
Thank you guys for helping.
(pretty stupid: all the time I considered that i have to put the whole path to my folder instead of just the /media/blabla/file )

Is there any way how I can limitate the filetype for only JPG / JPEG / BMP / PNG / GIF ?

Thanks for any suggestion.

Best Regards,
Stefek
« Last Edit: September 04, 2008, 04:20:32 PM by Stefek » Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
erpe

Offline Offline

Posts: 2077


WWW
« Reply #14 on: September 04, 2008, 04:13:09 PM »

Does it make sense to have files like

file04092008040935-yourfile.txt

in your media directory?

What is the reason for renaming a file "yourfile.txt" in "file04092008040935-yourfile.txt" by uploading it ?

Any suggestions?

rgds

erpe
Logged

sharmpro

Offline Offline

Posts: 64



WWW
« Reply #15 on: September 04, 2008, 04:21:59 PM »

Hi there,
i have already limited the file .ext (for graphics only) into my mods locally,
i even use PEAR Upload package in order to ensure portability/compatibility and security
but honestly this bit & pieces type of work will not bring substantial benefit to WB...
There're more than a couple  of mod based on Form aot there, with several new feature but
living a stand-alone life..

Is there a way someone picks up the module and work it out as a complete project?
Getting suggestions, bugs & feedback from the community and implement these into the mod....


BTW I rename the file w/timestamp in order to 'hide' it from the user.... even if he upload a 'worm.php' program
he'll not be able to link it directly... and execute...



Regards

Stefano
Logged

Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4755



« Reply #16 on: September 04, 2008, 04:29:52 PM »

Hi there,
i have already limited the file .ext (for graphics only) into my mods locally

Hallo Stefano!
I would appreciate if you let me know how to do this.

Regards,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
erpe

Offline Offline

Posts: 2077


WWW
« Reply #17 on: September 04, 2008, 09:30:08 PM »

Quote
BTW I rename the file w/timestamp in order to 'hide' it from the user.... even if he upload a 'worm.php' program
he'll not be able to link it directly... and execute...

That makes sense.............

rgds

erpe
Logged

ecology

Offline Offline

Posts: 117



WWW
« Reply #18 on: September 09, 2008, 07:02:43 PM »

hi together
first of all i have to thank to this great module!
the only thing what i had to change is, when i get the mail from the contact i would like to see the name of this person in the email-adress... like -> Hans Muster (hans.muster@mail.com)
in the settings you can fill in a name by hand but then every mail-address has the same name.
so i had to change the code of this a bit and now i can choose the fild witch is the name of the sender.
if you like you can add this code too as follow:

1.) modify_settings.php

search for:
Code:
   <tr>
        <td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['NAME']; ?>:</td>
        <td class="setting_name">
            <input type="text" name="email_fromname" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw$friendly, ($setting['email_fromname'])); ?>" />
        </td>
    </tr>

replace with:
Code:
   <tr>
        <td class="setting_name" width="30%"><?php echo $TEXT['EMAIL'].' '.$TEXT['NAME']; ?>:</td>
        <td class="setting_name">
            <select name="email_fromname" style="width: 98%;">
            <option value="" onclick="javascript: document.getElementById('email_fromname').style.display = 'block';"><?php echo $TEXT['NONE']; ?></option>
            <?php
            $email_fromname 
str_replace($raw$friendly, ($setting['email_fromname']));
            
$query_email_fields $database->query("SELECT field_id,title FROM ".TABLE_PREFIX."mod_formx_fields WHERE section_id = '$section_id' AND ( type = 'textfield' OR  type = 'email' ) ORDER BY position ASC");
            if(
$query_email_fields->numRows() > 0) {
                while(
$field $query_email_fields->fetchRow()) {
                    
?>

                    <option value="field<?php echo $field['field_id']; ?>"<?php if($email_fromname == 'field'.$field['field_id']) { echo ' selected'$selected true; } ?> onclick="javascript: document.getElementById('email_from').style.display = 'none';">
                        <?php echo $TEXT['FIELD'].': '.$field['title']; ?>
                    </option>
                    <?php
                
}
            }
            
?>

            </select>
        </td>
    </tr>    

--------------------------------------
2.) view.php

search for:
Code:
$email_fromname = $fetch_settings['email_fromname'];

replace with:
Code:
$email_fromname = $fetch_settings['email_fromname'];
            if(substr($email_fromname, 0, 5) == 'field') {
                // Set the email from field to what the user entered in the specified field
                $email_fromname = htmlspecialchars($wbx->add_slashes($_POST[$email_fromname]));
            }

That's all... smiley hope you'll like it smiley
cya ecology

so,... first code had a bug... but this is "clean" now...
« Last Edit: September 09, 2008, 08:44:11 PM by ecology » Logged

echo "hello world" ;-?
-------------------------------
sharmpro

Offline Offline

Posts: 64



WWW
« Reply #19 on: September 09, 2008, 07:58:12 PM »

Hi Ecology,
thank you for the useful add-on.
I'll upgrade the module to version 1.1.d with your code and with the possibility to restrict the type of file will be possible to upload that was requested on a previous post.

Regards

Stefano
Logged

Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4755



« Reply #20 on: September 09, 2008, 10:12:27 PM »

That's a geat addition in fact.

I have another idea what would be helpfull and could be implemented (easy I think) into the module.

If I look into the list of recieped mails inside the backend I can choose one of them.
Than the whole massage and the uploaded file path can be seen.
I would like it more, if we have a link instead of the path.
Do you understand what I'm thinking of, Stefano?

Regars,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
sharmpro

Offline Offline

Posts: 64



WWW
« Reply #21 on: September 10, 2008, 01:25:28 AM »

Hi,
Already done in module 1.1.d...

Stefano
Logged

bb_team

Offline Offline

Posts: 5


« Reply #22 on: September 12, 2008, 01:05:48 PM »

hello, thank you fo uploadingr 1.2 smiley
i was frustrated with the default form module and this one makes things much easier.

just a question, though:
wouldn't it be smart to insert the form data in the database not as a simple text but as a serialized array?
it would then be easier to analyze and use the collected data, both in wb (result table could be ordered by field) and by generating a hypotetical csv file which would be importable in spreadsheet programs.

Logged
Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4755



« Reply #23 on: September 12, 2008, 01:16:17 PM »

Hallo Stefano.

I had just one single Problem:
if you set "UPLOAD FILE" as required you can not send the form.

Can anyone agree with this?

Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
sharmpro

Offline Offline

Posts: 64



WWW
« Reply #24 on: September 12, 2008, 02:58:12 PM »

Hi,
bb-team had a nice idea... save the sumbmitted data into a serialized array... Will be implemented soon

File Upload required..... is still not 100% implemented... It'll be also soon in the next release.


Thank you for your feedbak.

Regards,

Stefano
Logged

Pages: [1] 2 3 ... 8   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!