[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 871
  • Last Modified:

Problems uploading files using .CreateTextFile

My problem happens when I upload an image file (.gif, or .jpg)

If I use:
Set myFile = scriptObject.CreateTextFile(serverPath1, True, False)

I get "Invalid procedure call or argument" at the .write line below:
 For loopIndex = 1 to LenB(value)
      myFile.Write chr(AscB(MidB(value, loopIndex, 1)))
Next

If I use:
Set myFile = scriptObject.CreateTextFile(serverPath1, True, True)

Then it creates the file ok, but I'm unable to open the image that was uploaded.

Thanks for your help.
0
kojak33
Asked:
kojak33
  • 5
  • 4
  • 2
1 Solution
 
peh803Commented:
I'm not sure about the details of what you're trying to accomplish, but if uploading is involved, I would recommend using a "tried and true" solution, like any of the free ones provided here:
http://www.taka.nl/programming/asp/comparing_fileupload.asp

Specifically, I've used the PseudoRequestDictionary with quite a bit of success in the past.

This is probably a better solution (although maybe not as fun) than trying to write your own.

Hope this helps!

Regards,
Phil / peh803
0
 
peterxlaneCommented:
Try setting both parameters to false:

Set myFile = scriptObject.CreateTextFile(serverPath1, False, False)

or leave them both off:

Set myFile = scriptObject.CreateTextFile(serverPath1)


The rest of what you have looks okay to me.  I, too would recommend using a component to do the uploading if that option is available to you.  Most all web hosts will have some sort of upload component that can do all the work in just a couple lines of code and provide much more flexibility and stability.

0
 
kojak33Author Commented:
It didn't help to change the parameters.  

This wasn't something I wrote on my own.  It was working for a long time, and then just quit working last week.  I don't have an old version though that does work, and I can't find any changes to the code.

I've tried implementing another component, and now I get an error:
Write to file failed.

at this line:

            Call lobjStream.SaveToFile(pstrFileName)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
peterxlaneCommented:
Is the new component set up in a different directory?  You have to make sure that you have write permissions on that directory.
0
 
kojak33Author Commented:
Actually for testing purposes, I gave Everyone write access to the directory that the file is being created in.

Still get that error.
0
 
kojak33Author Commented:
I'm looking into the PseudoRequestDictionary
0
 
peh803Commented:
I believe that this sometimes happens when certain anti-virus software settings are enabled ... be back in a minute or two with further details on this...

Regards,
Phil / peh803
0
 
peh803Commented:
According to the poster of that question:

Yeah, I was running Norton Antivirus with "Enable Script Blocking" combined with "Ask me what to do" option, which however never fired. Thanks a lot!

Regards,
Phil
0
 
kojak33Author Commented:
The PseudoRequestDictionary  is working GREAT.   Extremely fast uploading.

Thanks all.
0
 
peh803Commented:
Glad to hear it!  I've also had success with it.

Regards,
Phil
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now