If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Uploading a file from a client machine to another SQL website server

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-09-03, 20:33
Kahuna900 Kahuna900 is offline
Registered User
 
Join Date: Sep 2003
Posts: 2
Question Uploading a file from a client machine to another SQL website server

Hello!

I'm having trouble getting files to upload through the browser from one machine to another. I can upload files from the browser to the SQL database if they are both on the same machine but I can't seem to get it to work when the client is on a different machine than the SQL server and website.

I get the following error:

Error Type:
ADODB.Stream (0x800A0BBA)
File could not be opened.

Strange thing is, I got this to work once, from another machine here at work but for some reason I must have changed something as it no longer works right.

*** CODE SAMPLE ***

strFilename = Request("filepath")

Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")

Dim stm
Set stm = Server.CreateObject("ADODB.Stream")

'Read the binary files from disk.
stm.Type = adTypeBinary
stm.Open
stm.LoadFromFile(strFilename) ***CRASHES HERE***

rs.Close
stm.Close

Set rs = Nothing
Set stm = Nothing
Reply With Quote
  #2 (permalink)  
Old 09-10-03, 11:20
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
That only works because LoadFromFile executes on the server, not on the client. You need to use the <input type="file"> in a form which sends the file to the server. Then you can put that BLOB into the database.

Look up some sites in Google on retrieving files from forms. You can do it with pure ASP, or you can purchase something like SAFileUp which puts all the components you need into a COM.
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #3 (permalink)  
Old 09-10-03, 12:36
Kahuna900 Kahuna900 is offline
Registered User
 
Join Date: Sep 2003
Posts: 2
Yes, I am using the type="file" input in my form, just didn't include it in the sample.

I'm trying to avoid using any third party alternatives at this point. I know it works as I've done it from another machine on the network, but I must have made some changes since as it no longer works. I have no problem inserting the blob into the database as I've done it many times when browsing the database/website while on the same machine.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On