What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Google Script doPost(): Get the full link (URL path) to the image

    Asked by hartgen on January 13, 2015 at 11:16 AM

    Dear all,

    I created a form that uses the "take photo" widget, which works pretty well: http://form.jotformpro.com/form/50122342701943

    With submission I'm posting all data to a Google apps script (by "doPost" method)

    Unfortunately the image will be postet only by ist filename "image.jpg".

    There is also a connection from the form to a Google spreadsheet. In the spreadsheet the collumn for the image has the value http://www.jotformpro.com/uploads/hartgen/50122342701943/296973945556506478/image.jpg.

    So there is the correct link in the spreadsheet.

    How can I implement to send the complete link of the image (like in the spreadsheet) by "doPost"?

    Best regards

    Jorg

     

    Page URL:
    http://form.jotformpro.com/form/50122342701943

    image link uploads jpg filename Google Script
  • Profile Image

    Answered by hartgen on January 13, 2015 at 11:48 AM

    After several testing the Image link is not sent at all any more. In the widget "take photo" it's not possible to find out the Name of the field containing the Image, because the Name is not listed in the properties of the field.

  • Profile Image

    Answered by Ben on January 13, 2015 at 01:03 PM

    Hi Jorg,

    You re only sent the name of the file and not the entire link over the POST setup.

    Now it is still easy to get the image shown to you following few simple steps:

    http://www.jotformpro.com/uploads/username/form_id/{$submissionID}/{$filename}

    You can see it in action based on the link you have given:

    http://www.jotformpro.com/uploads/hartgen/50122342701943/296973945556506478/image.jpg

    Now it is important to know that the username and form ID is something that you know as soon as you create the jotform and as such can implement into the script right away.

    The second part is more interesting:

    /{$submissionID}/{$filename}

    Both of them are sent to you within the POST data and as such you can get them like so (in PHP):

    $_POST['submission_id'] and

    $_POST['file_upload_field_name'].

    What this means is that you can create the a (link) element and set its href attribute using the link built in the manner mentioned above.

    Do let us know if that helps you.

    Best Regards,
    Ben

  • Profile Image

    Answered by hartgen on January 13, 2015 at 03:16 PM

    Hi Ben,

    we're getting near to it, but haven't reached the goal:

     

    submission_id: Has been posted

    file_upload_field_name: Seems not to be postet. I get an "undefined".

     

    Here is my code from google apps:

    belegurl is the var that should show the correct url of the uploaded file. But it doesn't.

    Could you please help?

     

    ####################################

    // Rechnungsmail erzeugen

     

    function doPost(e) {

     

      var parameter

      var wert

      

      for (var i in e.parameters) {

        parameter = i;

        wert =  e.parameters[i];

        

        if (parameter == "belegdatei") {var belegdatei = wert;}

        if (parameter == "rechnungsnummer") {var rechnungsnummer = wert;}

        if (parameter == "ihrekundennummer") {var ihrekundennummer = wert;}

        if (parameter == "rechnungsdatum") {var rechnungsdatum = wert;}

        if (parameter == "rechnungsbetragbrutto") {var rechnungsbetragbrutto = wert;}

        if (parameter == "emailbeleg") {var emailbeleg = wert;}

        if (parameter == "feedbacktext") {var feedbacktext = wert;}

        if (parameter == "emailfeedback") {var emailfeedback = wert;}

        if (parameter == "submission_id") {var submission_id = wert;}

        if (parameter == "file_upload_field_name") {var file_upload_field_name = wert;}

       

      }

        //Weitere Variablen bilden

        var AdditionalEmailAdresses = "joerg.hartgen@googlemail.com"; //, hartgen@energieautonom.de";

        var EmailEmpfaengerliste = emailbeleg + ", " + AdditionalEmailAdresses;

       

       //Bild der Rechnung herunterladen

       var belegurl = "http://www.jotformpro.com/uploads/hartgen/50122342701943/" + submission_id + "/" + file_upload_field_name;

     

      return HtmlService.createHtmlOutput("Beleg-Url: " + belegurl);

     ####################################

     

     

  • Profile Image

    Answered by Ben on January 13, 2015 at 03:24 PM

    Hi Jorg,

    This is my fault, I do apologize for this. I wanted to add that "file_upload_field_name" is the name of the field on your jotform that you are sending the data from, seems that I did not do so.

    In your case this would be belegdatei.

    In the end it should like like this: http://pastebin.com/XTqfQqMU

    Do let us know how it goes and once again I apologize for not giving more details in my previous response in regards to the field name.

    Best Regards,
    Ben

  • Profile Image

    Answered by hartgen on January 13, 2015 at 03:29 PM

    Hi Ben,

    it works, thanks a lot!

    Best Regards,

    Jorg

  • Profile Image
    JotForm Support

    Answered by EltonCris on January 13, 2015 at 04:40 PM

    On behalf of my colleague Ben, you're welcome.

    Cheers!