我尝试将图片直接从浏览器上传到Cloudinary,但我尝试了配置。我跟着这个tutorial 而且我仍然坚持我需要包含的步骤:
var cloudinary_cors = "https://" + request.headers.host + "/cloudinary_cors.html";
我收到错误说"请求未定义"。模板页面确实呈现,但输入字段不执行任何操作。我也有" cloudinary_cors.html"我的静态目录中的文件,我使用Pug作为我的模板引擎。这是我到目前为止的模板页面:
//upload.pug
extends layout
block content
script(type='text/javascript', src='jquery.min.js')
script(type='text/javascript', src='/javascripts/jquery.ui.widget.js')
script(type='text/javascript', src='/javascripts/jquery.iframe-transport.js')
script(type='text/javascript', src='/javascripts/jquery.fileupload.js')
script(type='text/javascript', src='/javascripts/jquery.cloudinary.js')
cloudinary.cloudinary_js_config()
script.
$(function() {
if($.fn.cloudinary_fileupload !== undefined) {
$("input.cloudinary-fileupload[type=file]").cloudinary_fileupload();
}
});
var cloudinary_cors = "http://" + request.headers.host + "/cloudinary_cors.html";
cloudinary.v2.uploader.image_upload_tag('image_id', {callback: cloudinary_cors});
form(action='/create', method='post')
.field
label Image ID
input(name='image_id')
button.ui.primary.button(type='submit') Post
答案 0 :(得分:1)