如何使用raphael.js onclick在html上传图像?

时间:2015-05-21 04:45:37

标签: jquery image upload raphael

我在HTML页面上添加了一个图标按钮,我使用raphael.js在其上添加了一个click事件。当我单击此图标按钮时,将打开文件浏览器,从中我可以选择我想要的任何图像并打开它。但我想知道如何处理所选图像并将其上传到HTML页面,因为当前所选图像没有上传并显示在html页面上。

请查看以下代码,并建议我解决此问题的解决方案。

 a.add_pic.click(this.add_pic);   // here I am clicking on the add_pic icon button


    this.add_pic = function()     //  this function gets invoked once the click event is fired
   {

         upload = true;
         var input = $(document.createElement('input')); 
         input.attr("type", "file");
         input.trigger('click');


       if (this.files && this.files[0] && upload) {
          var reader = new FileReader();
          reader.onload = imageIsLoaded;
          reader.readAsDataURL(this.files[0]);
          upload=false;
      }


    }



        function imageIsLoaded(e) 
      {           
          // code to upload and display image file on html page
      }

0 个答案:

没有答案