Results 1 to 8 of 8

Thread: File renaming

  1. #1
    Join Date
    Oct 2010
    Posts
    4

    Default File renaming

    Hi, guys...

    I need some help regarding file renaming.

    The situation is this:
    I've got a form where i want the form result be sent by mail via csv file with an user upload file (Id name PD_UserUpload).

    I make both things to work as I needed, with the exception that I want to rename the files to a form field, i.e, one of the fields is "PD_zipcode", and I wish to rename both files to that field. I've tried derived files, file_name function (which only works partially, using the example at the how to guides), and also using both in conjunction which gives me always an error when receiving the email). The basic code I'm using is as follow:

    <!--go to template for CSV and send as test.csv-->
    <input type="hidden" name="mail_options" value="PlainTemplate=WABC.txt,AlwaysList" />
    <input type="hidden" name="filter_options" value="Attach=test.csv" />
    <input type="hidden" name="filter" value="null" />

    And the fields for the user upload is:

    <td class="RightBorder BottomBorder"><input name="PD_UserUpload" type="file" id="PD_UserUpload" size="58" /></td>

    And finally the zipcode code is:

    <input name="PD_ZipCode" type="text" id="PD_ZipCode" size="58" />


    Can someone give me a help here.

    Thanks in advance.

  2. #2
    Join Date
    Mar 2004
    Posts
    2,224

    Default Re: File renaming

    wot's the error ur getting....that will tell us wot the problem is

  3. #3
    Join Date
    Oct 2010
    Posts
    4

    Default Re: File renaming

    Finally, 50% of the problems solved.

    The userupload file is working as I want. The file the user user uploads is being renamed according to the zipcode field. Strange, I've tried the same solution yesterday (I think...was too tired) and didn't work.

    So the solution is to add this line to your form:

    <input type="hidden" name="file_names" value="PD_UserUpload=PD_ZipCode.%2E%.%ext(PD_UserUpload)%" />

    Now, the only thing missing is the renaming of the csv file...This one is really confusing me...

    Crabtree, I don't get any error on the mail neither in the csv file, everything is ok. The only thing is to make formmail rename the csv file (the test.csv) to the zipcode field.

    Thanks for the help.

  4. #4
    Join Date
    Mar 2004
    Posts
    2,224

    Default Re: File renaming

    <input type="hidden" name="filter_options" value="Attach=test.csv" />
    so, u want to name the attachment generated from the filter?

    to do that, u need to generate a "filter_options" field with the right value.

    u can do this with derive_fields:
    HTML Code:
    <input type="hidden" name="derive_fields" value="filter_options=%'Attach'%.%3D%.PD_Zipcode.%2E%.%'csv'%" />
    (or something like that)

  5. #5
    Join Date
    Oct 2010
    Posts
    4

    Default Re: File renaming

    Hi again....


    Well I tried your suggestion but didn't work. I don't get any error from formmail, but now i also don't receive any csv attachment. Now the form results are displayed at the body of the message (email), but no attachment.
    My basic setup to receive the form result as csv file by mail is:

    <input type="hidden" name="filter_options" value="Attach=test.csv" />
    <input type="hidden" name="filter" value="null" />

    Where the last line tell to formmail to send the form result as a csv file, i believe. Must I need to change/add (not delete because I tried and the result was the same, no file) that line?

    Thanks

  6. #6
    Join Date
    Mar 2004
    Posts
    2,224

    Default Re: File renaming

    one small typo will break things

    pls post the url for ur form so I can check wot u did

  7. #7
    Join Date
    Mar 2004
    Posts
    2,224

    Default Re: File renaming

    sorry, i've been offline for a few days....

    i got ur PM.

    ur code looks right, but i checked formmail and my suggestion isn't going to work.

    u cannot derive some special fields coz derivation occurs *after* the special fields are processed

    filter_options is one of these that cannot be derived.

    which means u need to generate this using PHP

    the best way is to use formmail's hook system.


    1. in formmail's config, set $HOOK_DIR = "."; (meaning "current directory")
    2. create a file called "fmhookpreinit.inc.php" with this content:
      PHP Code:
      <?php
      $_POST
      ["filter_options"] = "Attach=".$_POST["PD_Mobile"].".csv";
      ?>
    3. upload fmhookpreinit.inc.php to the same directory as formmail

    that should work

    u can always add debug with:
    PHP Code:
    SendAlert("This is my debug message"); 

  8. #8
    Join Date
    Oct 2010
    Posts
    4

    Default Re: File renaming

    crabtree,

    work perfectly.

    Thanks so much for your help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem renaming uploaded files
    By jspangler in forum Community Support
    Replies: 3
    Last Post: 10-Feb-2009, 03:01 PM
  2. Replies: 2
    Last Post: 11-Jul-2007, 07:03 AM
  3. Problem renaming uploaded file
    By blueroo in forum Community Support
    Replies: 4
    Last Post: 06-Jun-2007, 08:16 AM
  4. Replies: 1
    Last Post: 23-Aug-2006, 09:32 PM
  5. renaming formmail.php
    By djkirstyjay in forum FormMail Subscription Support
    Replies: 1
    Last Post: 12-Aug-2005, 09:31 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •