Image upload

Jo San
  • Jo San

    Jo San - 2002-12-05

    I'm curious as to the final intention of the image insert. Write now it attempts to browse my home dir and fails because of security policies. If I let it, I get the image name but of course that means a broken link when the htnl is rendered on the page I edited since no image was uploaded. Am I missing something here?   I'm looking to use this for a cms and have a java guy that can do some work on it so I'd like to know the direction intended and current status.  Is there a nice way to get permissions instead of an exception error? and is it possible (i.e. easy) to have the selected image be uploaded?  OR can this thing browse the server directory instead for previously uploaded images?


    • Howard Kistler

      Howard Kistler - 2002-12-06

      The image insertion is actually functional but blocked by the applet security model. I have done tests with fake security certificates and enabled the image insertion (as well as other security-blocked features) with no problem.

      The issue here is twofold:

      1) Security certificates cost money. $200 a year, currently, from Thawte for a Java security certificate. Ekit is open source and free software, and in spite of getting over 100 requests from users about getting images to load, no one has ever offered to contribute to the cost of the cert. Even if they did, it would still have to be renewed every year, so I'd probably have to charge people for the applet to affprd the renewals, and that's counter to the whole purpose of open source for me.

      2) I would be the only one who could sign the applet. So if you or anyone else wanted to make changes to the applet, you wouldn't be able to sign the modified code, and all the security blocks would kick in again. Once more, this is counter to the purpose of open source to me.

      Until either Sun offers a way around these issues or some company begins offering Java security certificates at a realistic price, these problems are going to exist in Ekit (and any other applet).

      Howard Kistler

    • Samuel Alfonso Velazquez Diaz

      You could also self sing you own applets if you users don't have a problem if the see a certificate signed by you, here are the steps to self sing you applet

      On windows:

      # create a keystore.
      keytool -genkey -keyalg rsa -alias AVAEditor -dname "CN=CN, OU=Your Organization unit, O=Your Organization, L=City, ST=State, C=Country" -keypass mypassword -validity 365 -keystore C:\java\ekit\ekit\keystore\myKeystore -storepass mypassword2

      # Selfsign certificate.
      keytool -selfcert -alias AVAEditor -dname "CN=CN, OU=Your Organization unit, O=Your Organization, L=City, ST=State, C=Country" -keypass mypassword -validity 180 -keystore C:\java\ekit\ekit\keystore\myKeystore -storepass mypassword2

      jarsigner -keystore C:\java\ekit\ekit\keystore\myKeystore -storepass mypassword -keypass mypassword -signedjar sekitapplet.jar ekitapplet.jar  AVAEditor

    • Daniel Cane

      Daniel Cane - 2003-03-17

      Samuel  - great post - very useful for testing.

      Joshua - you can use JAVA serialization to get your images onto the server and render them from there.

      Basically, you are doing a HTTP POST to a servlet which will contain the image. Then render the FQDN to the image. I would be more than happy to send you the JAVA code I used to do this. It's fairly straightforward.

      Also, I did find a "bug" where images with spaces in the path do not render correctly. This was easily fixed by changing the code in EkitCore:

      ~line 1422
                              String strText = "<IMG SRC=\&quot;" + strURLtoImage + "\&quot;>";
                  htmlKit.insertHTML(htmlDoc, caretPos, strText, 0, 0, HTML.Tag.IMG);


      Daniel Cane

      • Samuel Alfonso Velazquez Diaz

        Even if you are not using a servlet on the server side, I have to implement a functionality into ekit to allow to save documents (images and text) against a PHP script.

        I haven't finished implementing this but so far I'm going to use class to perform a POST and I'm sending the HTML document as a parameter and all the images as ENCODE64 parameters....

        hope it helps!

    • Daniel Cane

      Daniel Cane - 2003-03-18

      Samuel - Yes, that is in effect what I'm doing. In the insertImage() method, I'm adding a routine which does the binary post over HTTP. My code is ~:

                      URL BbUploadServlet = new URL( strDst );
                      URLConnection servletConnection = BbUploadServlet.openConnection();


                      servletConnection.setRequestProperty("Content-Type", "application/octet-stream");
                      System.out.println("Creating new serialized object");

                      BbCourseImage BbCImage= new BbCourseImage(strCourseId,strContentId, fileSrc);
                      ObjectOutputStream outputToServlet = null;
                      System.out.println("Sending Data to the Servlet");

                      outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());


                      BufferedReader inFromServlet = null;

                      System.out.println("Reading Servlet Response...");

                      inFromServlet = new BufferedReader(new InputStreamReader(servletConnection.getInputStream()));
                      String str;
                      while (null != ((str = inFromServlet.readLine()))) {
                          System.out.println("Reading servlet response: " + str);
                          strReturn = str;


      Basically, I'm storing the image in a byte array and then serializing the object to the server. You could, just as easily, just send the image itself over the OutputStream!  Since I have a servlet on the other end, I can do this easily, but you should be able to use PHP (or anything) that can accept the POST.

      Best of luck,


    • jakster

      jakster - 2003-12-07

      I've added a simple function that is called from javascript with a complete image url. Uploading happens in a new window, and when it is finishd it call parent.ekit.addimage(url). This was the easiest way.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks