• Login
sketchucation logo sketchucation
  • Login
🔌 Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

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 12 Sept 2012, 09:29

    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
    • C Offline
      chrisglasier
      last edited by 12 Sept 2012, 09:53

      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
      • T Offline
        thomthom
        last edited by 12 Sept 2012, 10:10

        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 13 Sept 2012, 14:38

          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
          • T Offline
            thomthom
            last edited by 13 Sept 2012, 14:52

            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 14 Sept 2012, 07:22

              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
              1 / 1
              • First post
                5/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement