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 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思