【问题标题】:Cloudinary OpenUpload widget is not opening in my jsCloudinary OpenUpload 小部件未在我的 js 中打开
【发布时间】:2017-12-30 20:52:28
【问题描述】:

我正在尝试在 cloudinary 中上传我的照片。所以,我也有一个云名称和 upload_preset。因此,我将 cloudinary 网站中给出的 javascript 集成到了我的 html 文件中。单击超链接,小部件应打开。但它没有打开。

请在下面找到我的 html 文件。如果我错过了未签名上传的任何参数,请告诉我。

<!DOCTYPE html>
<html>
    <head>
        <title>Button</title>
    </head>
    <body>

        <a href="#" id="upload_widget_opener">Upload multiple images</a>

        <script src="//widget.cloudinary.com/global/all.js" type="text/javascript"></script>  

        <script type="text/javascript">  
          document.getElementById("upload_widget_opener").addEventListener("click", function() {
            cloudinary.openUploadWidget({ cloud_name: 'mycloudname', sources: [ 'local', 'url', 'camera', 'image_search', 
                         'facebook', 'dropbox', 'google_photos' ], upload_preset: 'myuploadpreset'}, 
              function(error, result) { console.log(error, result) });
          }, false);
        </script>
    </body>
</html>

【问题讨论】:

    标签: javascript html cloudinary


    【解决方案1】:

    它看起来很好并且工作正常。

    <!DOCTYPE html>
    <html>
        <head>
            <title>Button</title>
        </head>
        <body>
    
            <a href="#" id="upload_widget_opener">Upload multiple images</a>
    
            <script src="//widget.cloudinary.com/global/all.js" type="text/javascript"></script>  
    
            <script type="text/javascript">  
              document.getElementById("upload_widget_opener").addEventListener("click", function() {
                cloudinary.openUploadWidget({ cloud_name: 'mycloudname', sources: [ 'local', 'url', 'camera', 'image_search', 
                             'facebook', 'dropbox', 'google_photos' ], upload_preset: 'myuploadpreset'}, 
                  function(error, result) { console.log(error, result) });
              }, false);
            </script>
        </body>
    </html>
    

    jsbin 示例 - https://jsbin.com/meyuwiyicu/edit?html,output

    也许从控制台分享错误日志?

    【讨论】:

    【解决方案2】:

    由于是未签名的上传,因此脚本的源代码中需要包含 http。

     src="//widget.cloudinary.com/global/all.js"
    

    必须替换为以下内容。

    src="https://widget.cloudinary.com/global/all.js"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      • 2020-11-30
      • 2021-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多