I’m working on a project that uses HubSpot for marketing and email campaigns. So far, I’ve been able to handle forms, email templates, and workflows using the HubSpot PHP API. Now I need to add a file upload feature to my forms.
I tried adding a file upload button to my form, but when I check the submissions, there’s no info about the uploaded files. I’m not sure if I’m doing something wrong or if there’s a special way to handle file uploads with HubSpot.
Has anyone successfully implemented file uploads for HubSpot forms using PHP or JavaScript? I’d really appreciate some guidance on how to get this working. Maybe there’s a specific method or approach I should be using?
Here’s a basic example of what I’ve tried so far:
$form_data = array(
'email' => '[email protected]',
'name' => 'John Doe',
'file' => '@/path/to/file.pdf'
);
$curl = curl_init('https://forms.hubspot.com/uploads/form/v2/{portal_id}/{form_id}');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $form_data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
Any tips or code snippets would be super helpful. Thanks!