当前位置: 网学 > 编程文档 > PHP > 正文

php中关于普通表单多文件上传的处理方法

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/21
mGet.Mode = 3
oStreamGet.Open
oStreamGet.Write formData
oStreamGet.Position = dataStart(i)
Set oStreamPut = Server.CreateObject("ADODB.Stream")
oStreamPut.Type = 1
oStreamPut.Mode = 3
oStreamPut.Open
oStreamPut.Write oStreamGet.Read(dataLength(i))
oStreamPut.SaveToFile filePath, 2
oStreamGet.Close
Set oStreamGet = Nothing
oStreamPut.Close
Set oStreamPut = Nothing
End If
End If
End If
Next
IsFinished = True
Else
IsFinished = False
End If
End Function

Private Function CheckFile
Dim oBoolean : oBoolean = True
CheckFile = oBoolean And CheckType And CheckSize
End Function

Private Function CheckType
Dim oBoolean : oBoolean = True
If fileType = "*" Then
oBoolean = oBoolean And True
Else
For i = 0 To itemCount - 1
If Not IsNothing(extenArr(i)) Then
If InStr(1, fileType, "|" & Ucase(Mid(extenArr(i), 2)) & "|") > 0 Then
If fIMGOnly Then
Dim sAllow : sAllow = "|GIF|PJPEG|X-PNG|BMP|"
Dim aCheck : aCheck = Split(UCase(httpArr(i)), "/")
Dim iCheck : iCheck = "|" & aCheck(Ubound(aCheck)) & "|"
If InStr(1, sAllow, iCheck, 1) > 0 Then
oBoolean = oBoolean And True
Else
sErrors = sErrors & "表单 [ " & itemName(i) & " ] 的文件格式错误!\n" & _
"支持的格式为:" & Replace(Mid(fileType, 2, Len(fileType) - 1), "|", " ") & "\n\n"
oBoolean = oBoolean And False
End If
Else
oBoolean = oBoolean And True
End If
Else
sErrors = sErrors & "表单 [ " & itemName(i) & " ] 的文件格式错误!\n" & _
"支持的格式为:" & Replace(Mid(fileType, 2, Len(fileType) - 1), "|", " ") & "\n\n"
oBoolean = oBoolean And False
End If
End If
Next
End If
CheckType = oBoolean
End Function

Private Function CheckSize
Dim oBoolean : oBoolean = True
If fileSize = "*" Then
oBoolean = oBoolean And True
Else
For i = 0 To itemCount - 1
If Not IsNothing(dataLength(i)) Then
Dim tmpSize : tmpSize = CDbl(FormatNumber(CCur(dataLength(i)) / 1024, 2))
If tmpSize <= fileSize Then
oBoolean = oBoolean And True
Else
sErrors = sErrors & "表单 [ " & itemName(i) & " ] 的文件大小 (" & tmpSize & " KB) 超出范围!\n" & _
"支持大小范围:<= " & fileSize & " KB\n\n"
oBoolean = oBoolean And False
End If
End If
Next
End If
CheckSize = oBoolean
End Function

Private Function CreateFolder(byVal sLine, byVal sPath)
Dim oFso
Set oFso = Server.CreateObject("Scripting.FileSystemObject")
If Not oFso.FolderExists(sPath) Then
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "^(.*)\\([^\\]*)$"
regEx.Global = False
regEx.IgnoreCase = True
sLine = sLine & regEx.Replace(sPath, "$2") & "|"
sPath = regEx.Replace(sPath, "$1")
If CreateFolder(sLine, sPath) Then CreateFolder = True
Set regEx = Nothing
Else
If sLine = "|" Then
CreateFolder = True
Else
Dim sTemp : sTemp = Mid(sLine, 2, Len(sLine) - 2)
If InStrRev(sTemp, "|") = 0 Then
sLine = "|"
sPath = sPath & "\" & sTemp
Else
Dim Folder : Folder = Mid(sTemp, InStrRev(sTemp, "|") + 1)
sLine = "|" & Mid(sTemp, 1, InStrRev(sTemp, "|") - 1) & "|"
sPath = sPath & "\" & Folder
End If
oFso.CreateFolder sPath
If CreateFolder(sLine, sPath) Then CreateFolder = True
End if
End If
Set oFso = Nothing
End F

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号