Re: File Upload Field

Anonymous
Not applicable

How do I set a form field that allows the user to upload file or image?

30 REPLIES 30
Jo_Pitts1
Level 10 - Community Advisor

As always @SanfordWhiteman , you are a legend.  I'll go experiment.

Jo_Pitts1
Level 10 - Community Advisor

@SanfordWhiteman,

Hmm... And I've manifestly failed.

I've been using this code

 

<!-- \ Mkto Munchkin lib / -->
<!-- / Mkto Forms 2.0 container, library, load form \ -->
<script src="//info.metlifecare.co.nz/js/forms2/js/forms2.min.js"></script><form id="mktoForm_185"></form><script> MktoForms2.setOptions({ formXDPath : "/rs/179-LVM-746/images/marketo-xdframe-relative.html" }); MktoForms2.loadForm("//info.metlifecare.co.nz", "179-LVM-746", 185);</script> 
<!-- \ Mkto Forms 2.0 container, library, load form / -->
<!-- / TEKNKL extended libraries \ -->
<script id="teknklSimpleDTO-1.0.4" src="https://metlifecare.co.nz/teknkl-simpledto-1.0.4.js"></script>
<!-- \ TEKNKL extended libraries / -->
<!-- / Call DTP to pre-fill form \ -->
<script>
  var DTO = new SimpleDTO({
  domain: "metlifecare.co.nz",
  dataSrc: "https://info.metlifecare.co.nz/MLC-Form-Pre-fill-Landing-Page.html",
  debug: true,
  mode: "receive",
  cb: function(instance){
  var mktoFields = DTO.getGlobal()["mktoPreFillFields"];  
  DTO.cleanup();  
  MktoForms2.whenReady(function(form) {
  form.setValuesCoerced(mktoFields);
 });
 }
 });
</script>
<!-- \ Call DTP to pre-fill form / --

 

 

which is a combo of your pre-fill and getting around cross domain tracking issues code... but can't work out how to make it work with my new stuff... 

Paul_Drago
Level 2

Hey Sanford,

I'd love to see a sample integration--  I am looking at this MktoForms2 :: Uploadcare  and I am wondering if that is the sample of which you speak? 

SanfordWhiteman
Level 10 - Community Moderator

Yep, that's a pretty good one. I added a little more validation just now.

There are other ways to insert the host INPUT element -- the element that gets augmented with the UploadCare widget HTML. Here you see I create the host element dynamically via addHiddenFields and then move it where I want in the form (i.e. at the top).

Paul_Drago
Level 2

Just got back to this and I used more or less the same implementation--  UploadCare widget, input the element into HTML.  Let UploadCare populate the URI.     Super Simple and clean concept-- thanks for the direction Sanford!

SanfordWhiteman
Level 10 - Community Moderator

Great!

Anonymous
Not applicable

HI,

How can it be included in an email alert when someone fills out the form ?

thanks

Paul_Drago
Level 2

Benolt,

Write the URL to a field in marketo-- then do something like <a href="My.Token">Click Here to Download</a>

Justin_Cooperm2
Level 10

You can't upload files right now, but you can add a textbox where they can insert a link to an image on the web and then store that. If you need to do file i/o, you'll have to write a custom adapter or use a 3rd party offering.

Justin_Cooperm2
Level 10

By the way, by "write a custom adapter" I mean leverage our APIs to create a file in Marketo. You would have to manage the I/O though.

Justin