• Resolved shivakumarcloud

    (@shivakumarcloud)


    “I am currently receiving only the file name instead of the file URL when using CF7 with webhook support. If I could get either the file URL or the file as multipart form data, I would be able to use it effectively in an integration. Could you please help me resolve this issue?”

    { “first-name”: “bhu”, “last-name”: “kum”, “your-email”: “[email protected]”, “country”: “United States”, “phone-number”: “2015551100”, “mfile-386”: [ “01/small_kitchen-removebg-preview-3.png” ] }

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mário Valney

    (@mariovalney)

    Hey. How are you?

    • Are you using any integration or it’s the core file input from CF7?
    • Is everything updated?

    (It’s pretty strange as we send the URL for a copied file.)

    Thread Starter shivakumarcloud

    (@shivakumarcloud)

    Yeah I am using a plugin Multifile Upload Field for Contact Form 7

    Plugin Author Mário Valney

    (@mariovalney)

    We support CF7 uploaded files (tag “file”).

    However I’ll check it’s possible to add this support in a future release.

    By now, maybe this code can help you:

    <?php

    add_filter( 'ctz_get_data_from_contact_form', 'multiline_files_contact_form', 10, 2 )
    function multiline_files_contact_form( $data, $contact_form ) {
    // Submission
    $submission = WPCF7_Submission::get_instance();
    $uploaded_files = ( ! empty( $submission ) ) ? $submission->uploaded_files() : [];

    // Upload Info
    $wp_upload_dir = wp_get_upload_dir();
    $upload_path = CFTZ_UPLOAD_DIR . '/' . $contact_form->id() . '/' . uniqid();

    $upload_url = $wp_upload_dir['baseurl'] . '/' . $upload_path;
    $upload_dir = $wp_upload_dir['basedir'] . '/' . $upload_path;

    $tags = $contact_form->scan_form_tags();
    foreach ( $tags as $tag ) {
    if ( $tag->basetype !== 'multilinefile' || empty( $uploaded_files[ $tag->name ] ) ) {
    continue;
    }

    $files = $uploaded_files[ $tag->name ];

    $copied_files = [];
    foreach ( (array) $files as $file ) {
    wp_mkdir_p( $upload_dir );

    $filename = wp_unique_filename( $upload_dir, $tag->name . '-' . basename( $file ) );

    if ( ! copy( $file, $upload_dir . '/' . $filename ) ) {
    $submission = WPCF7_Submission::get_instance();
    $submission->set_status( 'mail_failed' );
    $submission->set_response( $contact_form->message( 'upload_failed' ) );

    continue;
    }

    $copied_files[] = $upload_url . '/' . $filename;
    }

    $value = $copied_files;

    if ( count( $value ) === 1 ) {
    $value = $value[0];
    }

    // Support to "webhook" option (rename field value)
    $key = $tag->name;
    $webhook_key = $tag->get_option( 'webhook' );

    if ( ! empty( $webhook_key ) && ! empty( $webhook_key[0] ) ) {
    $key = $webhook_key[0];
    }

    $data[ $key ] = $value;
    }

    return $data;
    }

    It’s just a copy and past of our plugin code using multilinefile tag name… Please, check it before going on production: I was not able to test in a working website.

    Thread Starter shivakumarcloud

    (@shivakumarcloud)

    Thanks, will try it out

    Plugin Author Mário Valney

    (@mariovalney)

    New version will support “Multifile Upload Field for Contact Form 7”.

    You may remove your custom code to avoid future problems.

    Thread Starter shivakumarcloud

    (@shivakumarcloud)

    Hi I tried, I am getting data like this no urls
    { “text”: “*New message!*\n\nan\nj\[email protected]\nGreece (\u0395\u03bb\u03bb\u03ac\u03b4\u03b1)\n6912345678\n[“01\/90bc0c906fc30587b4863d0e6089f364-removebg-preview-13.png”,”01\/Vinayaka-24-13.png”,”01\/lord-ganesha-vector-34-10.png”,”01\/Super-store-offer-flyer-Made-with-PosterMyWall-11.jpg”]” }

    and I am sorry, I mentioned wrong plugin

    plugin name: Drag and Drop Multiple File Upload – Contact Form 7

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Need Help with File URL in CF7 Webhook Integration”’ is closed to new replies.