sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Uploading image file from Webdialog to php-script?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 579 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      tafkab76
      last edited by

      Hi!

      I´m trying to send a jpeg file from the webdialog to a php-script to save it server-side. The background is, that I want to create a little preview of the Sketchup model with the write_image function which shall be used for further purposes. I already found out, that I can´t upload a file with javascript for security reasons, so I use a form within the Webdialog. Inside this form there is a filechosser and an invisible iframe. The invisible iframe will recieve the php answer, so that the webdialog won´t reload or some other unwanted behaviour will occur.

      Now my problem is, when clicking the submit button the php-script ist not beeing called, nor is the onsubmit event beeing triggered and it looks like the ruby script creating the webdialog reloads. I searched this forum for solutions and found that probably it´s not possbile to submit forms with an

      <input type="submit"/>
      

      element.

      Of course I could use a normal button instead and bind a function to it, but how will I get the chosen image-file within the form to be uploaded to the php-script?

      Any ideas?

      This is my html code so far:

      <form id="frm_icon_upload" action="icon_upload.php" method="post" enctype="mulitpart/form-data" onsubmit="debugAlert()">
          <input type="submit" name="action" value="Upload"/>
          <input type="file" name="icon" id="icon"/>
          <iframe id="upload_target" name="puload_target" src="" style"..."></iframe>
      </form>
      
      1 Reply Last reply Reply Quote 0
      • chrisglasierC Offline
        chrisglasier
        last edited by

        If you sit a url in a webdialog you can use something like http://www.tizag.com/htmlT/htmlupload.php

        With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Never use the method, but: WebDialog.post_url
          https://developers.google.com/sketchup/docs/ourdoc/webdialog#post_url

          ❓

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • T Offline
            tafkab76
            last edited by

            Thanks for your advices. I have tested the post_url method before, but I guess you can only submit the values of <input> elements like text areas or buttons in the url, no images. I decided to drop that feature for now, may I will implement it later. There seem´s to be another approach using the flash file upload abbility, may be I´ll give it a try then.

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              You could BASE64 encode the image...

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • T Offline
                tafkab76
                last edited by

                I didn´t know about that possibility and it really seems to be just what I´m looking for. I will definitely give it try.

                Thanks!

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement