Dim endpoint As String = "https://oss-cn-shenzhen.aliyuncs.com" '你的阿里云oss地域节点Dim accessKeyId As String = "xxxxxxxxxxxxxxxx"
Dim accessKeySecret As String = "xxxxxxxxxxxxxxxx"
Dim bucketName As String ="mbldt" '存储空间的名称
Dim client As New Aliyun.OSS.OssClient(endpoint, accessKeyId, accessKeySecret) '根据SDK创建阿里云oss对象
Dim LocalPath As String = "c:\123.zip"
Dim UpLoadPath As String = "demo1/222.zip" '上传后的文件路径 demo/ABC.txt ,不存在的文件夹会自动创建,同名的文件自动覆盖
Try
client.PutObject(bucketName ,UpLoadPath ,LocalPath )
MessageBox.show("上传成功")
Catch ex As Exception
MessageBox.show("上传失败,原因" & ex.Message)
End Try
上面代码什么改成下面这个
For Each key As String In e.Files.Keys
If key = "up1" Then
Dim lst As List(of String) = dr.Lines("开支图片")
For Each fln As String In e.Files(key)
Dim sr() As String = fln.split(".")
Dim ss As String = e.Cookies("username") & Format(Date.Now,"yyMMddHHmmssfffff") & "." & sr(sr.length - 1)
'Dim sr() As String = fln.split(".")
'Dim ss As String = dr("编号") & format(Date.now ,"yyMMddHHmmssfffff") & "." & sr(sr.length - 1)
Dim ddr As DataRow= DataTables("Users").SQLFind("Name='"& e.Cookies("username") &"' " )
e.SaveFile(key,fln, "D:\web\img\"&ddr("Name")&"\"& Format(Date.Now,"yyyy") &"\"& Format(Date.Now,"MM") &"\" & ss)
lst.Add(ss)
Next
dr.Lines("开支图片") = lst
End If
Next
If e.PostValues.ContainsKey("up1_deleted") Then
Dim Files = e.PostValues("up1_deleted").Split("|")
Dim lst As List(of String) = dr.Lines("开支图片")
For Each File As String In Files
lst.Remove(File.Trim(".").Replace("img/",""))
file = "d:\web\" & File.Trim(".")
If Filesys.FileExists(file) Then
Filesys.DeleteFile(file)
End If
Next
dr.Lines("开支图片") = lst
End If
dr.save()