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

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


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:////"]

obviously it should just be:

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!



User Gravatar


Posted Dec 10 2013 6:01 UTC


  • Assigned To davedavedave
  • Solved
  • php

1 Replies

I have now solved this myself - I think.

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


Change from:

                case "fileupload" :
                    $file_path = $value;
                        $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;

to this:

        case "fileupload" :
            $output =  $format == "text" ? "" : "<ul>";
                $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;

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

Dave :)

User Gravatar


Posted Dec 10 2013 7:13 UTC


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