Thank you! Your feedback has been delivered
Thank you! Your feedback has been sent

Gravit Forms PDF Extended doesn't handle multi-file uploads

Hello!

I'm currently running Wordpress 3.71 with Gravity Forms 1.8 beta 3 alongside Gravity Forms PDF Extended 3.2.0.

Having created a simple form with a text field and an multi-file upload option, I filled it in and submitted it.

I got my email notification and PDF attachment as expected, but the multi-file upload isn't handled correctly by the GF PDF Extended plugin.

When I turn off the multi-file upload, the PDF Extended plugin works fine.

The issue is that when multi-file is enabled, the PDF displays a hyperlink (the file name) with "] added to the end. The url itself is then formatted as:

http://example.com/["http:////example.com//wp-content//uploads//gravity_forms//1-91729a51f8b177b6feed5eac9293a627//2013//12//ip5.png"]

obviously it should just be:

http://example.com/wp-content/uploads/gravity_forms/1-91729a51f8b177b6feed5eac9293a627/2013/12/ip5.png

I contact GF and they said go back to GF PDF Extended who will have to fix the way the multi-file is handled. I was given the following code:

if ( $field["multipleFiles"] ) {
    $uploaded_files = json_decode( stripslashes( $entry[$id] ), true );

    foreach ( $uploaded_files as $uploaded_file ) {
       // do something with a file from a multi-file upload field
    }
} else {
    // do something with a single file upload field entry
}

I really need this fixing!

If you need any more info, just shout!

Thanks.

Dave

User Gravatar

davedavedave

Posted Dec 10 2013 6:01 UTC

$50


  • Assigned To davedavedave
  • Solved
  • php
    wordpress
    gravity-forms
  • 938 Views

1 Replies


I have now solved this myself - I think.

Change lines 957-965 inclusive in the pdf-entry-detail.php

public_html/wp-content/plugins/gravity-forms-pdf-extended/pdf-entry-detail.php

Change from:

                case "fileupload" :
                    $file_path = $value;
                    if(!empty($file_path)){
                        $info = pathinfo($file_path);
                        $file_path = esc_attr(str_replace(" ", "%20", $file_path));
                        $value = $format == "text" ? $file_path : "<a href='$file_path' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $info["basename"] . "</a>";
                    }
                    return $value;
                break;

to this:

        case "fileupload" :
            $output =  $format == "text" ? "" : "<ul>";
            if(!empty($value)){
                $output_arr = array();
                $file_paths = rgar($field,"multipleFiles") ? json_decode($value) : array($value);
                foreach($file_paths as $file_path){
                    $info = pathinfo($file_path);
                    $file_path = esc_attr(str_replace(" ", "%20", $file_path));
                    $output_arr[] = $format == "text" ? $file_path . PHP_EOL: "<li><a href='$file_path' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $info["basename"] . "</a></li>";
                }
                $output = join(PHP_EOL, $output_arr);
              }
            $output .=  $format == "text" ? "" : "</ul>";
            return $output;
        break;

There may be a cleaner or quicker way of doing this, but it does appear to have resolved the issue.

Dave :)

User Gravatar

davedavedave

Posted Dec 10 2013 7:13 UTC

Solution

This didn't solve your task? Get your own custom solution.

Add a reply

By posting a reply on CodersClan you agree to our Terms & Conditions