Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2004, 11:17 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBScript Error on Image upload - help!

Hi All,
This is my first msg on the board and I would appreciate some early replies as I am struggling with a deadline here....

My ASP page is using the Jacob "Beezle" Gilley's upload.asp code to upload Image files to a web server. However, I am facing this error,

Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument
/Presentation/Content/ET03/members/utilities/upload.asp, line 209

and the Line 209 is the line in the loop:
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)- 1
   oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
Next

I read at many forums and the problem seems to be the AscB is trying to read at a place where it does not find any data. And it can happen at random. Sometimes 1Kb and sometimes 2Kb of the file data is written before the error is thrown. None of the forums have given me a good solution.....please any help will be greatly appreciated!

Thanks,
NG

 
Old August 16th, 2004, 03:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

You say you are using that code to upload image files? Why are you attemting to convert the contents of an image file to characters? Why don't you just save them off in binary format?
 
Old August 16th, 2004, 09:11 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am not well experienced with ASP...could you provide me with a sample code or modify the current one as a guideline for me to look into...? I would really appreciate that...
-Natasha

 
Old August 16th, 2004, 10:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

See function 1a) "SaveBinaryData" here http://www.motobit.com/tips/detpg_re...nary-files.htm

Then replace the code you posted with:
Call SaveBinaryData(sPath & FileName, FileData)
 
Old August 16th, 2004, 11:09 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I tried using this but it throws me the exception:
Error Type:
ADODB.Stream (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/Presentation/Content/ET03/members/utilities/upload.asp, line 226

I think this is due to the fact that the function is expecting Binary data and the FileData has been modified as follows in our file:
============================
nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
nPosBegin = nPos + 14
nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
nPosBegin = nPosEnd+4
nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
===========================

Should removing this statement and then supplying oUploadFile.FileData as the parameter directly, rsolve the problem? I am trying this right now but would appreciate your expert guidance...
Thanks
Natasha

 
Old August 16th, 2004, 12:35 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried with only supplying the FileData as retrived in the above statement and it does not take it. Gives the error I reported earlier.
How else can I retrieve the parameter "FileData"? Otherwise I am not being able to use this fucntion...
-Natasha

 
Old August 16th, 2004, 01:32 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The below code can only be used in VB not in ASP. However, you could encapsulate the code into a DLL and call the DLL from ASP

Public Function BinaryRead(Byval Path as String) As String
   On Error Goto EH
   Dim strFileData as String * 200000

   Open Path For Binary Access Read as #1
   Get #1,,strFileData
   Close #1
   BinaryRead = strFileData
   Exit Function
EH:
   Err.Raise vbObjectError,Err.Source,Err.Description
End Function
 
Old August 17th, 2004, 04:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

OIC, all you need to do is convert it back to binary before you try and write it into the stream. So, in SaveBinaryData function, replace the line
Code:
BinaryStream.Write ByteArray
with this:
Code:
If VarType(ByteArray) = 8 Then
    BinaryStream.Write MultiByteToBinary(ByteArray)
Else
    BinaryStream.Write ByteArray
End If
Then you'll also need the MultiByteToBinary function, which you can find here:
http://www.motobit.com/tips/detpg_binarytostring.htm
 
Old May 14th, 2006, 02:20 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to manzil Send a message via Yahoo to manzil
Default

Hi,
I tried using this but it throws me the exception:
Error Type:- Microsoft VBScript runtime (0x800A0005)
              Invalid procedure call or argument: 'MidB'

ADODB.Stream (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/Presentation/Content/ET03/members/utilities/upload.asp, line 226

I think this is due to the fact that the function is expecting Binary data and the FileData has been modified as follows in our file:
============================
nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
nPosBegin = nPos + 14
nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
nPosBegin = nPosEnd+4
nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
boundary = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
===========================

Should removing this statement and then supplying oUploadFile.FileData as the parameter directly, rsolve the problem? I am trying this right now but would appreciate your expert guidance...
Thanks
Natasha
 
Old May 15th, 2006, 06:12 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to manzil Send a message via Yahoo to manzil
Default

Yes different users can post images with the same name and they should be renamed as you state.

However you can not upload an image with the same name if you have already done so and give msgbox that duplicate image name pls check image name and image size is not larger then 13kb.

You got it

dhar





Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload image-create & save thumbnail-display image angshujit ASP.NET 2.0 Professional 6 July 11th, 2013 10:34 PM
how to upload image? vipin k varghese BOOK: XSLT Programmer's Reference, 2nd Edition 3 June 3rd, 2008 02:53 AM
ASP vbscript dynamic image display johneecc Classic ASP Professional 10 January 31st, 2008 01:34 PM
Image Upload spbharti Pro PHP 3 February 3rd, 2006 08:20 AM
Image upload Pallav Javascript How-To 8 October 21st, 2004 12:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.