Home › Forums › Quform WordPress › File Upload empty on cURL redirect
- This topic has 2 replies, 2 voices, and was last updated 11 years ago by Pew446.
- AuthorPosts
- January 6, 2014 at 1:09 am #8073Pew446Participant
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!
January 6, 2014 at 2:29 pm #8101AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 7, 2014 at 4:15 am #8120Pew446ParticipantThanks 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. 🙂
- AuthorPosts
- You must be logged in to reply to this topic.