I have the following code:
Public Sub Save(path)
Dim streamFile, fileItem, filePath, allowedExtensions
allowedExtensions = ".jpg, .gif, .png, .zip, .7z, .exe, .bmp, .pdf, .doc, .docx"
if Right(path, 1) <> "\" then path = path & "\" '"
if not uploadedYet then Upload
For Each fileItem In UploadedFiles.Items
Dim MyArray, extension
MyArray = Split(fileItem, ".")
extension = MyArray(UBound(MyArray)-1)
'' # var extension = UCase(right(fileItem.FileName,5,);
if(allowedExtensions.Contains(extension)) then
filePath = path & fileItem.FileName
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = adTypeBinary
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile filePath, adSaveCreateOverWrite
streamFile.close
Set streamFile = Nothing
fileItem.Path = filePath
end if
Next
End Sub
I cannot seem to get this line correct:
MyArray = Split(fileItem, ".")
The browser is telling me:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method
/up/freeaspupload.asp, line 90
Everywhere I look up, it shows this is how you do it.
Anyone have any ideas what I am doing wrong or a way around this?
I just want to only allow certain extensions to be uploaded.