473,804 Members | 3,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(sPat h)
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.CreateOb ject("Scripting .FileSystemObje ct")
If Not oFS.FolderExist s(sPath) Then Exit Sub

Set oFile = oFS.CreateTextF ile(sPath & FileName, True)

For nIndex = 1 to LenB(FileData)
n = Chr(AscB(MidB(F ileData,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.as p" method="post" enctype="multip art/form-data">
....
</form>

Can anyone help me? Any help greatly appreciated!

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


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(sPat h)
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.CreateOb ject("Scripting .FileSystemObje ct")
If Not oFS.FolderExist s(sPath) Then Exit Sub

Set oFile = oFS.CreateTextF ile(sPath & FileName, True)

For nIndex = 1 to LenB(FileData)
n = Chr(AscB(MidB(F ileData,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.as p" method="post" enctype="multip art/form-data">
....
</form>

Can anyone help me? Any help greatly appreciated!


Some people run into trouble with the FileSystemObjec t after installing
some virus scanner or firewall that tries to disable the
fileSystemObjec t 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*******@yaho o.de> wrote in message
news:eB******** ******@TK2MSFTN GP09.phx.gbl...
Some people run into trouble with the FileSystemObjec t after installing
some virus scanner or firewall that tries to disable the
fileSystemObjec t 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(sPat h)
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.CreateOb ject("Scripting .FileSystemObje ct")
If Not oFS.FolderExist s(sPath) Then Exit Sub

Set oFile = oFS.CreateTextF ile(sPath & FileName, True)

For nIndex = 1 to LenB(FileData)
n = Chr(AscB(MidB(F ileData,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.as p" method="post" enctype="multip art/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
filesystemobjec t.
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(sPat h)
Dim oFS, oFile
Dim nIndex

If sPath = "" Or FileName = "" Then Exit Sub
If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"

Set oFS = Server.CreateOb ject("Scripting .FileSystemObje ct")
If Not oFS.FolderExist s(sPath) Then Exit Sub

Set oFile = oFS.CreateTextF ile(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.AppendCh unk 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(St ring,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 = RSBinaryToStrin g(Binary)
If Len(TempString) <> LenB(Binary) then'Conversion error
'We have to use multibyte version of BinaryToString
TempString = MBBinaryToStrin g(Binary)
end if
BinaryToString = TempString
End Function
Function MBBinaryToStrin g(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(B inary,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
MBBinaryToStrin g = pl1 & pl2 & pl3
End Function
Function RSBinaryToStrin g(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 MBBinaryToStrin g 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 = MultiByteToBina ry(xBinary) else
Binary = xBinary

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

if LBinary>0 then
RS.Fields.Appen d "mBinary", adLongVarChar, LBinary
RS.Open
RS.AddNew
RS("mBinary").A ppendChunk Binary
RS.Update
RSBinaryToStrin g = RS("mBinary")
Else
RSBinaryToStrin g = ""
End If
End Function
Function MultiByteToBina ry(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("A DODB.Recordset" )
LMultiByte = LenB(MultiByte)
if LMultiByte>0 then
RS.Fields.Appen d "mBinary", adLongVarBinary , LMultiByte
RS.Open
RS.AddNew
RS("mBinary").A ppendChunk MultiByte & ChrB(0)
RS.Update
Binary = RS("mBinary").G etChunk(LMultiB yte)
End If
MultiByteToBina ry = 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
7098
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 where it's going on the server is correct (checked through prints etc.). I've changed the dir to 777 (is that right?) and this is what I get on the print_r($_FILES); line:
7
4541
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" ACTION="UploadAction.asp" METHOD="POST" enctype=multipart/form-data> <input type="file" name="fileName"> //etc ... </FORM>
6
3619
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 the user selected the too large file, the page is redirected to a "page not found" error page. 3. This is as per the docs, but my question is:
6
2972
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 the request and saves the file to disk (on the server). My .net side works if I use a simple html file input and post it, I've read in the uploaded request (multipart form), and reproduced it in the java applet. Everything works fine when I upload...
15
5369
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 path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
0
789
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 by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
3
14063
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 by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
6
6806
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 /home/.gobbles/mahcuz/mahcuz.com/upload/uploaded.php on line 129 And this is some of the code from the page: /* New code for thumbnails. Will on work if user selects "create thumb on upload" on the upload page */ //check to see if checkbox is...
1
10498
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 my upload.savevirtual : Set Upload = Server.CreateObject("Persits.Upload") upload.savevirtual ("test/") .. ''''error:
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10569
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10325
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.