473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Write Error on Upload

This drives me crazy: I have a file upload script to save an image on
the disk (and later on in the database)... it used to work and now it
doesn't, though I didn't change anything within the file upload script
itself.
The file-uploader was originally written by Jacob Gilley and I get the
following error:

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument
cls-file-uploader.asp, line 139

In this code:

Public Sub SaveToDisk(sPath)
Dim oFS, oFile
Dim nIndex
dim n

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)
n = Chr(AscB(MidB(FileData,nIndex,1)))
oFile.Write n '<------ fires error after some loops
Next

oFile.Close
End Sub

I also tried error handling etc. with no results -- the image saved to
disk will always be around 1K but not the full image. IIS was restarted
several times to no avail.
By the way my upload form looks like this:

<form action="save.asp" method="post" enctype="multipart/form-data">
....
</form>

Can anyone help me? Any help greatly appreciated!

--
Google Blogoscoped
http://blog.outer-court.com
Jul 19 '05 #1
4 10746


Philipp Lenssen wrote:
This drives me crazy: I have a file upload script to save an image on
the disk (and later on in the database)... it used to work and now it
doesn't, though I didn't change anything within the file upload script
itself.
The file-uploader was originally written by Jacob Gilley and I get the
following error:

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument
cls-file-uploader.asp, line 139

In this code:

Public Sub SaveToDisk(sPath)
Dim oFS, oFile
Dim nIndex
dim n

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)
n = Chr(AscB(MidB(FileData,nIndex,1)))
oFile.Write n '<------ fires error after some loops
Next

oFile.Close
End Sub

I also tried error handling etc. with no results -- the image saved to
disk will always be around 1K but not the full image. IIS was restarted
several times to no avail.
By the way my upload form looks like this:

<form action="save.asp" method="post" enctype="multipart/form-data">
....
</form>

Can anyone help me? Any help greatly appreciated!


Some people run into trouble with the FileSystemObject after installing
some virus scanner or firewall that tries to disable the
fileSystemObject from file access.
As you get some data written that is not likely to be the problem but
check whether you have installed something like that.

As for the error can you debug what value n has when you get
Invalid procedure call or argument
it might be that there is something wrong with that argument.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 19 '05 #2
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:eB**************@TK2MSFTNGP09.phx.gbl...
Some people run into trouble with the FileSystemObject after installing
some virus scanner or firewall that tries to disable the
fileSystemObject from file access.


Good point.

--
Tom Kaminski IIS MVP
http://www.microsoft.com/windowsserv...y/centers/iis/
http://mvp.support.microsoft.com/
http://www.iisfaq.com/
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://www.tryiis.com
Jul 19 '05 #3
"Philipp Lenssen" <in**@outer-court.com> wrote in message
news:2n***********@uni-berlin.de...
This drives me crazy: I have a file upload script to save an image on
the disk (and later on in the database)... it used to work and now it
doesn't, though I didn't change anything within the file upload script
itself.
The file-uploader was originally written by Jacob Gilley and I get the
following error:

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument
cls-file-uploader.asp, line 139

In this code:

Public Sub SaveToDisk(sPath)
Dim oFS, oFile
Dim nIndex
dim n

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)
n = Chr(AscB(MidB(FileData,nIndex,1)))
oFile.Write n '<------ fires error after some loops
Next

oFile.Close
End Sub

I also tried error handling etc. with no results -- the image saved to
disk will always be around 1K but not the full image. IIS was restarted
several times to no avail.
By the way my upload form looks like this:

<form action="save.asp" method="post" enctype="multipart/form-data">
....
</form>

Can anyone help me? Any help greatly appreciated!


FWIW, I wouldn't try to save a binary image file using the text-based
filesystemobject.
http://support.microsoft.com/default...92&Product=asp
http://www.aspfaq.com/show.asp?id=2189

--
Tom Kaminski IIS MVP
http://www.microsoft.com/windowsserv...y/centers/iis/
http://mvp.support.microsoft.com/
http://www.iisfaq.com/
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://www.tryiis.com
Jul 19 '05 #4
Martin Honnen wrote:

As for the error can you debug what value n has when you get
Invalid procedure call or argument
it might be that there is something wrong with that argument.


I couldn't read out "n" -- it was always showing as an empty string,
but there were some other oddities attached to it I can barely describe!
Thanks for the help to you and others. I finally managed to find
another script to workaround this critical portion of my old script
(which worked for years):

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)
oFile.Write BinaryToString(FileData) <--- this was the error line

oFile.Close
End Sub

Public Sub SaveToDatabase(ByRef oField)
If LenB(FileData) = 0 Then Exit Sub

If IsObject(oField) Then
oField.AppendChunk FileData
End If
End Sub
' Following via PureASP Uploader ---------------

Function StringToBinary(String)
Dim I, B
For I=1 to len(String)
B = B & ChrB(Asc(Mid(String,I,1)))
Next
StringToBinary = B
End Function

Function BinaryToString(Binary)
'2001 Antonin Foller, PSTRUH Software
'Optimized version of PureASP conversion function
'Selects the best algorithm to convert binary data to String data
Dim TempString

On Error Resume Next
'Recordset conversion has a best functionality
TempString = RSBinaryToString(Binary)
If Len(TempString) <> LenB(Binary) then'Conversion error
'We have to use multibyte version of BinaryToString
TempString = MBBinaryToString(Binary)
end if
BinaryToString = TempString
End Function
Function MBBinaryToString(Binary)
'1999 Antonin Foller, PSTRUH Software
'MultiByte version of BinaryToString function
'Optimized version of simple BinaryToString algorithm.
dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L', nullchar
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(Binary)

Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
if cl3>300 then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
if cl2>200 then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
MBBinaryToString = pl1 & pl2 & pl3
End Function
Function RSBinaryToString(xBinary)
'1999 Antonin Foller, PSTRUH Software
'This function converts binary data (VT_UI1 | VT_ARRAY or MultiByte
string)
'to string (BSTR) using ADO recordset
'The fastest way - requires ADODB.Recordset
'Use this function instead of MBBinaryToString if you have
ADODB.Recordset installed
'to eliminate problem with PureASP performance

Dim Binary
'MultiByte data must be converted to VT_UI1 | VT_ARRAY first.
if vartype(xBinary) = 8 then Binary = MultiByteToBinary(xBinary) else
Binary = xBinary

Dim RS, LBinary
Const adLongVarChar = 201
Set RS = CreateObject("ADODB.Recordset")
LBinary = LenB(Binary)

if LBinary>0 then
RS.Fields.Append "mBinary", adLongVarChar, LBinary
RS.Open
RS.AddNew
RS("mBinary").AppendChunk Binary
RS.Update
RSBinaryToString = RS("mBinary")
Else
RSBinaryToString = ""
End If
End Function
Function MultiByteToBinary(MultiByte)
' This function converts multibyte string to real binary data (VT_UI1
| VT_ARRAY)
' Using recordset
Dim RS, LMultiByte, Binary
Const adLongVarBinary = 205
Set RS = CreateObject("ADODB.Recordset")
LMultiByte = LenB(MultiByte)
if LMultiByte>0 then
RS.Fields.Append "mBinary", adLongVarBinary, LMultiByte
RS.Open
RS.AddNew
RS("mBinary").AppendChunk MultiByte & ChrB(0)
RS.Update
Binary = RS("mBinary").GetChunk(LMultiByte)
End If
MultiByteToBinary = Binary
End Function

--
Google Blogoscoped
http://blog.outer-court.com
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Amy Kimber | last post by:
Hello, I have a file upload page, and I've had it working fine, it was beautiful :-) Anyway, the powers that be moved hosts... and it doesn't work now. The file name is correct, the directory...
7
by: Joe | last post by:
I have an upload file operation in the web application. UploadForm.asp is the form, and UploadAction.asp is the form processing. //UploadForm.asp <FORM NAME="InputForm"...
6
by: Paul | last post by:
Hi there, When adding a "File Field" HTML control to an aspx page to facilitate file uploading, the following occurs: 1. You select a file that is larger than the allowed size limit. 2. Once...
6
by: Jason Chu | last post by:
situation: I'm uploading file to my application using a java applet sending the request (the file) through socket to my asp.net page. On my asp.net page, I've override the httpmodule to take in...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
6
Markus
by: Markus | last post by:
I'm adding to my script a section that allows a thumbnail to be created and saved. I get this error: Warning: imagejpeg() : Unable to open '../uploads/thumb/' for writing: Is a directory in...
1
by: .Net Sports | last post by:
I'm using Persits.upload module in ASP, and when i use the following form pointed to the object I've always used, i get a "The system cannot find the file specified" error pointing to the line of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.