I'm setting up a custom form with image upload, all client side.
I've tried to use the V2 and can submit images successfully with multipart/form-data header, but the V2 doesnt seem to allow CORS requests so I cannot do this client side in the browser.
I also can't get a similar request to work with the V3 API, which does appears to allow CORS.
File uploads via Forms are handled by associating the upload to a property; I am unsure of your current method, once the form is submitted, we will see the property update to reflect a link to the file itself.
To add to this, you can pass a file URL through theForms API, but itwon'tautomatically upload the file to the HubSpot file manager like it does when you manually submit a form.
I'm trying to use a custom form with client side browser image cropping, along with text fields, which submits to HubSpot. This doesn't seem possible with the APIs since I can't submit an image client side.
My workaround for anyone trying something similar is to embed the HubSpot form in raw HTML and hide it with CSS. Then create a custom HTML form, which is the one users will interact with. Now bind the custom forms text inputs to the Hubspot form. This takes care of the text.
For the image, do any client side cropping first, and set the outputted cropped image as a selected file in the hidden hubSpot form using the JS File API.
File uploads via Forms are handled by associating the upload to a property; I am unsure of your current method, once the form is submitted, we will see the property update to reflect a link to the file itself.
To add to this, you can pass a file URL through theForms API, but itwon'tautomatically upload the file to the HubSpot file manager like it does when you manually submit a form.
I'm trying to use a custom form with client side browser image cropping, along with text fields, which submits to HubSpot. This doesn't seem possible with the APIs since I can't submit an image client side.
My workaround for anyone trying something similar is to embed the HubSpot form in raw HTML and hide it with CSS. Then create a custom HTML form, which is the one users will interact with. Now bind the custom forms text inputs to the Hubspot form. This takes care of the text.
For the image, do any client side cropping first, and set the outputted cropped image as a selected file in the hidden hubSpot form using the JS File API.