javascript - 七牛上傳圖片的問題
問題描述
如果我一個頁面、有兩個地方上傳圖片但是我想他們的key不同,要怎么才能分開不沖突呢,我現在的做法是創建兩個文件
var uploader1= Qiniu.uploader({’Key’: function(up, file) { var now = new Date(); var date = now.getFullYear()+((now.getMonth()+1)<10?'0':'')+(now.getMonth()+1)+(now.getDate()<10?'0':'')+now.getDate(); return 'topic/cover/'+date;},})var uploader2= Qiniu.uploader({ ’Key’: function(up, file) { var now = new Date(); var date = now.getFullYear()+((now.getMonth()+1)<10?'0':'')+(now.getMonth()+1)+(now.getDate()<10?'0':'')+now.getDate(); return 'topic/banner/'+date;}, })})
但是這樣做為什么key會相同呢
問題解答
回答1:key不同是指?
回答2:知道了,原來需要實例化
var Qiniu1 = new QiniuJsSDK()var Qiniu2 = new QiniuJsSDK()var uploader1= Qiniu1 .uploader({})var uploader2= Qiniu2 .uploader({})
相關文章:
1. python - flask sqlalchemy signals 無法觸發2. 為什么python中實例檢查推薦使用isinstance而不是type?3. mysql里的大表用mycat做水平拆分,是不是要先手動分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. python - 獲取到的數據生成新的mysql表6. python - (初學者)代碼運行不起來,求指導,謝謝!7. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現 4048. linux - 【已解決】fabric部署的Python項目Apache啟動之后提示403Forbidden該如何解決?9. python的文件讀寫問題?10. javascript - js 對中文進行MD5加密和python結果不一樣。
