duandu5846 2016-10-29 22:52
浏览 56
已采纳

Cloudinary jQuery文件上传 - 选择后图像无法上传

I'm trying to test the Cloudinary Uploader (via jquery and PHP). I follow the instructions there: http://cloudinary.com/documentation/php_image_upload#direct_uploading_from_the_browser

I'm interested to make it work as browser uploading (not server side).

My final HTML/script text is the following (I put some XXXX).

<html>
        <head>
            <title></title>
            <script src="js/jquery-3.1.1.min.js"></script>
            <script src='js/jquery.ui.widget.js' type='text/javascript'></script>
            <script src='js/jquery.iframe-transport.js' type='text/javascript'></script>
            <script src='js/jquery.fileupload.js' type='text/javascript'></script>
            <script src='js/jquery.cloudinary.js' type='text/javascript'></script>
        </head>
<body>
<script type='text/javascript'>
$.cloudinary.config({"api_key":"XXXXX","cloud_name":"XXXXX"});
</script>

<form action="uploaded.php" method="post">
      <input class='cloudinary-fileupload' data-cloudinary-field='image_id' data-form-data='{"timestamp":1477780986,"callback":"http:\/\/www.XXXXX.XXX\/cloudinary\/cloudinary_cors.html","signature":"96872da4909f6acf00537c78ca41414ea73bXXXXX","api_key":"538456726987XXX"}' data-url='https://api.cloudinary.com/v1_1/di2a8qkzv/auto/upload' name='file' type='file'/>    <input type="hidden" name="image_id" id="image_id" />
</form>
</body>
</html>

I just click the "Browse..." button and select a file, but nothing happens. I have also the Firefox Console ON, but also I don't see any action.

As I understand, the form should automatically submit after the selection of the file. Right? If not, what exact should I do to submit the file to Cloudinary?

What escapes me?

  • 写回答

2条回答 默认 最新

  • douba1498 2016-10-31 11:02
    关注

    You have to initialize the input field as well. Try adding your code the following:

    $('.cloudinary-fileupload').cloudinary_fileupload();
    

    Make sure that this line is loaded last, so either put it at the end of the HTML or put it in a $( document ).ready() block.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的