var uniqueId
var files = ""
var db = 0
upload.render({
elem: '#ID-upload-demo-btn-2',
url: '../pnxpsc', //
data: {
bj: function() {
return $('#bjxz').val();
},
db: function() {
$('input[type="checkbox"][name="BBB"]:checked').each(function() {
var number = parseFloat($(this).attr('value'))
db += number
});
return db;
},
filename:function(){
return uniqueId;
},
},
headers: {
token: 'sa'
},
multiple: true,
auto: false,
bindAction: "#ID-upload-demo-btn-3",
choose: function(obj) {
// $('#upload-demo-preview').empty;
files = obj.pushFile();
console.log(files)
obj.preview(function(index, file, result) {
$('#upload-demo-preview').append('<img src="' + result + '">').find('img').css({
widhth: 92,
height: 92,
margin: '0 10px 10px 0'
})
})
}
});
Dim e As RequestEventArgs = args(0)
Dim bj As String = e.values("bj")
Dim db As Double=e.values("db")
Dim xpid=e.values("filename")
'Dim i As Integer=1
For Each key As String In e.files.keys
For Each fl As String In e.files(key)
e.savefile(key,fl,"/web/xp/wjxp/" & xpid & "-" & i &".jpg"
Next
i=i+1
Next
Dim obj As new Jobject
obj("status")="ok"
e.Writestring(obj.Tostring)
e.Handled=True ''
请问老师,你好,这个是前端牟取预览有多个文件,想上传后在后台将每个文件用 xpid连个i的形式来保存文件,现在是几个图片传过来文件名只有第一个,请问问题在哪里,该怎样改?谢谢
估计是前端添加文件时没有添加文件名。自行使用浏览器开发者工具跟踪一下前端的执行过程
有文件,现在的问题是传后台想把上传的几个图片文件分别存在为xpid-"X"的形式,如AA-1,AA-2
此主题相关图片如下:微信图片_20241008215642.png
调试看看接收到几个
For Each key As String In e.files.keys
msgbox(key )
For Each fl As String In e.files(key)
msgbox(fl )
e.savefile(key,fl,"/web/xp/wjxp/" & xpid & "-" & i &".jpg"
Next
i=i+1
Next
Dim e As RequestEventArgs = args(0)
Dim bj As String = e.values("bj")
Dim db As Double=e.values("db")
Dim xpid=e.values("filename")
Dim i As Integer=1
For Each key As String In e.files.keys
For Each fl As String In e.files(key)
msgbox(fl )
e.savefile(key,fl,"/web/xp/wjxp/" & xpid & "-" & i &".jpg")
Next
i=i+1
Next
前端 测试了弹出的了三个文件,但这样最终后只有存在xpid-1一个,也就是每次都存为1号文件了去了,所以不前端一次多个文件,最后保存结果都只有xpid-1,这怎么办
Dim i As Integer=1
For Each key As String In e.files.keys
For Each fl As String In e.files(key)
msgbox(fl )
e.savefile(key,fl,"/web/xp/wjxp/" & xpid & "-" & i &".jpg")
i=i+1 Next
Next
Dim e As RequestEventArgs = args(0)
Dim bj As String = e.values("bj")
Dim db As Double=e.values("db")
Dim xpid=e.values("filename")
Dim i As Integer = rand.Next(1000000)
For Each key As String In e.files.keys
For Each fl As String In e.files(key)
msgbox(fl )
e.savefile(key,fl,"/web/xp/wjxp/" & xpid & "-" & i &".jpg")
Next
i=i+1
Next
老师,终于懂起了layui前端多文件上传时是有多少个就调多少次接口,所以每一次i都为1,所以就成这样了,我用了随机数,这样就能解决了,虽解决了上传不履盖,但这不是我想要的最好结果
老师:接着再提点问,现在多文件传成功了。现有表中图片文件名为AAAA,现在对应文件夹中存有AAAA-ahdjhk.jpg,AAAA-djlskl.jpg等个数不定的文件,相在fox中点到表记录时用图片控件来显示各对应的多个文件,怎么做,没有思路,请指点,谢谢
[此贴子已经被作者于2024/10/10 20:37:16编辑过]
获取文件夹中所有AAAA-开头的文件名参考:
Dim files() As String = System.IO.Directory.GetFiles("d:\xxx文件夹" , "AAAA-*.jpg")
然后遍历逐个添加到图片控件