2017-11-11 97 views
0

我試圖直接從瀏覽器上傳圖片到Cloudinary,但我嘗試的配置。我下面這個tutorial 和我卡在臺階上,我需要包括此:Cloudinary Nodejs圖片上傳設置問題

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 

回答