title: ASP File Extension Split
body: <p>I have the following code:</p>
  
  <pre><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) &lt;&gt; "\" then path = path &amp; "\" '"
  
      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 &amp; 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
  </code></pre>
  
  <p>I cannot seem to get this line correct:</p>
  
  <pre><code>MyArray = Split(fileItem, ".")
  </code></pre>
  
  <p>The browser is telling me:</p>
  
  <blockquote>
    <p>Microsoft VBScript runtime error '800a01b6'</p>
    
    <p>Object doesn't support this property or method</p>
    
    <p>/up/freeaspupload.asp, line 90</p>
  </blockquote>
  
  <p>Everywhere I look up, it shows this is how you do it.</p>
  
  <p>Anyone have any ideas what I am doing wrong or a way around this? </p>
  
  <p>I just want to only allow certain extensions to be uploaded.</p>