File Upload empty on cURL redirect

Home Forums Quform WordPress File Upload empty on cURL redirect

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8073
    Pew446
    Participant

    Hi! I am using a form to send a file to another PHP script along with some other fields, and every field is returning the correct value except the file upload field which seems to be empty.

    Here’s an image of my form setup:

    And the code in functions.php:

    function quform_post_Uploader($form)
    {
    // Create a new cURL resource
    $ch = curl_init();

    $post = array(
    'file' => $_POST['iphorm_1_1'],
    'clientType' => $_POST['iphorm_1_2'],
    'changeLog' => $_POST['iphorm_1_3'],
    'userName' => $_POST['iphorm_1_4'],
    'passWord' => $_POST['iphorm_1_5']
    );

    // Set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, 'http://mywebsite.com/Uploader/upload.php');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));

    // Send the request
    curl_exec($ch);

    // Close cURL resource, and free up system resources
    curl_close($ch);
    }
    add_action('iphorm_post_process_1', 'quform_post_Uploader');

    And then how I access the file variable:

    $file = $_POST['file'];
    $fileUrl = $file[0]['url'];
    $fileText = $file[0]['text'];

    But when I print the fileUrl/Text to a file using:
    file_put_contents(“error_log.txt”, “File Url: “.$fileUrl.”\nFile Text: “.$fileText.”\n”, FILE_APPEND | LOCK_EX);

    All that comes out is:
    “File Url:
    File Text:”

    Am I doing something wrong here? All the other fields show up fine, like changeLog, etc.
    Is it possible to redirect the user to the php page kind of like what would happen if you used <form action=”foo.php”> except while still checking required fields and such that QuForm does?

    Thanks!

    #8101
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #8120
    Pew446
    Participant

    Thanks Ally! Your second method worked for me. I wasn’t able to get the first method working, maybe I did something wrong, but the second one works great. 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy