我试图测试Cloudinary Uploader(通过jquery和PHP)。 我按照那里的指示: http://cloudinary.com/documentation/php_image_upload#direct_uploading_from_the_browser
我有兴趣让它作为浏览器上传工作(而不是服务器端)。
我的最终HTML /脚本文本如下(我放了一些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>
我只需点击&#34;浏览...&#34;按钮并选择一个文件,但没有任何反应。 我也开启了Firefox控制台,但我也没有看到任何动作。
据我了解,表格应在选择文件后自动提交。对? 如果没有,我应该怎样做才能将文件提交给Cloudinary?
什么逃避了我?
答案 0 :(得分:0)
在文件输入上附加:
(gdb) p FUNCTION_LENGTH(test)
$2 = 42
(gdb) n
[New Thread 5920.0x282c]
a(1), b(2)
16ew Thr ((func_test) func)(1, 2);
(gdb) s
0x000006ffffff0000 in ?? ()
(gdb)
Cannot find bounds of current function
更改此行代码:
onchange="this.form.submit();"
为:
<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>
答案 1 :(得分:0)
您还必须初始化输入字段。尝试添加以下代码:
$('.cloudinary-fileupload').cloudinary_fileupload();
确保最后加载此行,因此要么将其放在HTML的末尾,要么将其放在$( document ).ready()
块中。