This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

element_7-22-Sunset.jpg


  1. tomsen
    Member

    Hi

    how can i get rid of the element_7-22- counter wen a user uplods a file

    Posted 16 years ago #
  2. yuniar

    It can't be removed.
    MachForm needs it to prevent your users overwriting the same file name.

    So if user A uploads Sunset.jpg and user B uploads another file with the same name Sunset.jpg, it won't overwrite the other file.

    However, those prefix are automatically removed when you download those files.


    MachForm Founder

    Posted 16 years ago #
  3. tomsen
    Member

    I understand that theory
    but i absolutely need to get rid of the prefix
    in whit’s file is the code for the upload function cant the prefix element be excluded

    Posted 16 years ago #
  4. yuniar

    Ok, If you are fine with the above potential problem and really need it. You will need to modify two files.

    1) includes/post-functions.php

    search around line 876-881, you'll find this code:

    //move file and check for invalid file
    $destination_file = DATA_DIR."/form_{$form_id}/files/{$element_name}-{$record_insert_id}-{$_FILES[$element_name]['name']}";
    if (move_uploaded_file($_FILES[$element_name]['tmp_name'], $destination_file)) {
    	$query = "update ap_form_{$form_id} set $element_name='{$element_name}-{$record_insert_id}-{$_FILES[$element_name]['name']}' where id='$record_insert_id'";
    	do_query($query);
    }


    replace it with this one:

    //move file and check for invalid file
    $destination_file = DATA_DIR."/form_{$form_id}/files/{$_FILES[$element_name]['name']}";
    if (move_uploaded_file($_FILES[$element_name]['tmp_name'], $destination_file)) {
    	$query = "update ap_form_{$form_id} set $element_name='{$_FILES[$element_name]['name']}' where id='$record_insert_id'";
    	do_query($query);
    }

    2) download.php

    search around line 32 - 34 for this code:

    //remove the element_x-xx- suffix we added to all uploaded files
    $file_1 	   =  substr($filename_only,strpos($filename_only,'-')+1);
    $filename_only = substr($file_1,strpos($file_1,'-')+1);


    remove the code above.

    That should do it.


    MachForm Founder

    Posted 16 years ago #
  5. tomsen
    Member

    ok Yuniar

    you are a Genus I love this product and I will be using this program for all me future clients

    Posted 16 years ago #

RSS feed for this topic

Reply