Hi everyone, I’m getting the following error uploading a file with asp. I’m using the code I downloaded from uploadasp.zip. I don’t know who wrote it so I can’t give credit.
I've checked my local dev box here and I do infact have the correct directory permissions as far as I can tell.

Mike

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument
/administration/DBupload/upload.asp, line 136

The code:

Public Sub SaveToDisk(sPath)
		Dim oFS, oFile
		Dim nIndex
	
		If sPath = "" Or FileName = "" Then Exit Sub
		If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"
	
		Set oFS = Server.CreateObject("Scripting.FileSystemObject")
		If Not oFS.FolderExists(sPath) Then Exit Sub
		
		Set oFile = oFS.CreateTextFile(sPath & FileName, True)
		
		For nIndex = 1 to LenB(FileData)
		    oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))	<-- Line 136
		Next

		oFile.Close
	End Sub

Dani AI

Generated

A quick diagnosis and a practical fix.

This failure usually happens when a script treats raw upload bytes as if they were normal text and then trips over a byte-oriented string call (index out of range, Null/empty value or an argument the routine does not expect). was right that pure‑ASP upload parsers are fragile; replacing the uploader (as eventually did) is a common, pragmatic solution.

Checklist to reproduce and isolate the problem:

  • Verify the upload buffer actually contains data and is not Null/empty (check the variable type and byte length rather than only character length).
  • Confirm any byte-index math uses byte-length (LenB) and that loop bounds match the byte count.
  • Make sure the target path exists, the filename is safe (no illegal chars), and the web process has write permission.
  • If the routine writes binary with text APIs, it can throw argument errors or corrupt the file.

A reliable replacement approach: avoid per-byte loops and use ADODB.Stream to write the binary block returned by Request.BinaryRead. Example pattern:

Dim bin, stm
bin = Request.BinaryRead(Request.TotalBytes)
Set stm = Server.CreateObject("ADODB.Stream")
stm.Type = 1            ' adTypeBinary
stm.Open
stm.Write bin
stm.SaveToFile Server.MapPath("/uploads/") & filename, 2  ' adSaveCreateOverWrite
stm.Close
Set stm = Nothing

This is binary-safe and far less error-prone than byte-by-byte MidB/AscB/Chr loops. For those who must parse multipart boundaries in pure ASP, use a well-tested parser or library — hand-rolled parsers are easy to get subtly wrong. and : using ADODB.Stream or a vetted uploader is the fastest path to a working, maintainable solution.

Most likely a problem with the file path... or the routine itself will never work. While a lot people use DLLs to process ASP uploads, it can be done using pure ASP, but the routines are much more complex than what your script suggests.

problem fixed by replacing the script with one that actually works.

I was wondering what script you found? I'm using this uploader that doesn't work either and I need one that does.

Thanks in advance.

It not uderstand code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.