APIs & Integrations

Shivasagar
Member

Form API: File field - AJAX

Hi Team,

 

I just want know procedure to pass file field of form using AJAX(here).

 

For example:

 

{

"name":"first_name",

"value":"TEST"

},

{

"name":"email,

"value":"test432@gmail.com"

},

{

"name":"resume",

"value":"What should be the value here for file input type"

}

 

Please Let me know where i'm wrong.

 

0 Upvotes
4 Replies 4
DRidenhour
Member

Form API: File field - AJAX

Hi @Willson ,

This is straightforward, but how do I submit multiple files to the same field?  I tried sending an array, but it didn't work.

Thanks,

-Dalton

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Form API: File field - AJAX

Heyo @DRidenhour !

If there are multiple files, you would duplicate the field for each file in your post

Here is another post answer that might help

0 Upvotes
DRidenhour
Member

Form API: File field - AJAX

@dennisedson Ok, I will try that!  Thank you.

One other question:

It looks like, for private files, I have to send a signed url, which I need to get via a separate API call (it doesn't come back with the normal file upload API call).  If I send a signed url with a form submission, what happens when it expires?  Does Hubspot update these, automatically?

Thank you,

Dalton

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

Form API: File field - AJAX

Hi @Shivasagar 

 

We do not currently provide the support of file uploads via our Forms API directly. Currently, if you wish to pass uploads via the Forms API, this must be done by passing a file URL to the form’s file upload field. The value will be stored as a string in a contact property.

 

However, if you wish to have this file stored in HubSpot' File Manager, you'll have to do this first through this server-side endpoint so that you get a file manager URL.

 

It's incredibly important here that you make sure to not set the property, hidden to the value of true. Once this step is complete, you will have the URL which you can then pass to the form field allowing you to use the intial method of passing this URL in the form's file upload field.

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes