Support » Plugin: Contact Form DB » Uploaded file moved to another location and add llink to file

  • Hello,
    at first I must say: your plugin is great.

    I do modification on uploaded file via Contact Form 7. I use your code from:

    File is moved to new location. But I will add new URL to the file in your table in admin. So, if I clicked to file name in table, I can download the file.

    Please, can you help me with this?

    Here is code, that I use:

    function cfdbFilter($formData){
    if($formData && ‘Udelenie grantu’ == $formData->title){

    $formCopy=clone $formData;
    $filename_new = file_newname($uploaddir, $filename);

    $newname = $uploaddir.$filename_new;


    $formCopy->posted_data[‘priloha’] = $filename_new;
    //$formCopy->posted_data[‘fileurl’] = ‘’;

    return $formCopy;

    return $formData;

    // add counter to file name if exist
    function file_newname($path, $filename){
    if ($pos = strrpos($filename, ‘.’)) {
    $name = substr($filename, 0, $pos);
    $ext = substr($filename, $pos);
    } else {
    $name = $filename;

    $newpath = $path.’/’.$filename;
    $newname = $filename;
    $counter = 0;
    while (file_exists($newpath)) {
    $newname = $name .’_’. $counter . $ext;
    $newpath = $path.’/’.$newname;

    return $newname;

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Michael Simpson


    Please use the “code” button to format code that you post. Otherwise it is hard to read.

    This line is to for you to set the URL for downloading your file from where you place it.
    //$formCopy->posted_data[‘fileurl’] = ‘’;

    But I don’t think it appears as a clickable link in the administration page. If using a shortcode, you can add some JavaScript to make the link active. See:

    Sorry for bad code formating. I do it with shortcode and little bit javascript.
    Many thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Uploaded file moved to another location and add llink to file’ is closed to new replies.