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. docker 下面創建的IMAGE 他們的 ID 一樣?這個是怎么回事????2. 在應用配置文件 app.php 中找不到’route_check_cache’配置項3. html按鍵開關如何提交我想需要的值到數據庫4. css - width設置為100%之后列表無法居中5. ios - vue-cli開發項目webstrom會在stylus樣式報錯,飆紅,請大神幫忙6. javascript - 一個頁面有四個圖片,翻頁的時候想固定住某個圖片然后翻頁,如何實現呢?7. css3 - 怎么感覺用 rem 開發的不多啊8. html5 - 用Egret寫的小游戲,怎么分享到微信呢?9. python - 在pyqt中做微信的機器人,要在表格中顯示微信好友的名字,卻顯示不出來,怎么解決?10. objective-c - 自定義導航條為類似美團的搜索欄樣式
