Skip to main content

I am trying to integrate my custom form to zapier to send files using webhook. I am using PHP to do so, what i am really trying to to do is that when a user uploads multiple files then all those files are addded to zip file and sent to webhook, till now the webhook is working as receiving the data but things get weird when i try to upload the zip file to the google drive, i cannot see the file object, just the file name, file Postname and file Mime. Below i have attached screenshots as well as my codebase.

zap records
$fileName = $_POST['fname'];
$zip = new ZipArchive;
$zipFileName = $fileName.'.zip';

if ($zip->open($zipFileName, ZipArchive::CREATE) === TRUE) {
foreach ($_FILES['firstImg']['tmp_name'] as $key => $value) {
if(!empty($_FILES['firstImg']['name'][$key])){
$unique_id = uniqid();
$file_name = $unique_id . '_' . $_FILES['firstImg']['name'][$key];
$zip->addFile($_FILES['firstImg']['tmp_name'][$key], $file_name);
}
}
$zip->close();
}
$zipFilePath = $zipFileName;
$upload_file = new CURLFile($zipFilePath, 'application/zip', basename($zipFilePath));

$post_data = array(
'file' => $upload_file
);

$headers = array(
'content-type: multipart/form-data'
);
$zap_array = http_build_query($post_data );

// get my zap URL
$zap_hook_url = "https://hooks.zapier.com/hooks/catch/XXXXXX/XXXXXX/";

// curl my data into the zap
$ch = curl_init($zap_hook_url);
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $zap_array);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch); //Log the response from HubSpot as needed.
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //Log the response status code
curl_close($ch);
unlink($zipFileName);