I am in need of some ideas on how to approach sending/uploading a peice of text(lets say like a username or something of that sort) to a place that i can view the peice of text with ease.
I'm not sure what the best way to approach this would be.
Printable View
I am in need of some ideas on how to approach sending/uploading a peice of text(lets say like a username or something of that sort) to a place that i can view the peice of text with ease.
I'm not sure what the best way to approach this would be.
You about an ASP script (simple) that will take the parameter passed and store it in an online DB? Then simply use Inet or whatever and hit that URL passing the text as a parameter ( www.google.com/script.asp?user=[whatever])
That sounds exactly like what i need.
The Inet part is no problem. But how would i go about creating the ASP script(i have no knowledge on that). Is there an example that i can view that functions the way i need it to?
ty
ASP works with VBScript (by default, but it can be JavaScript too), so adapting to it will be a breeze. For example:
That will get you the string the user passed in the parameter called "user".Code:Dim strUsername
strUsername = Request.QueryString("user")
But since you are storing this you should also make a function for data sanitizing (to protect against SQL injection attacks and such).
When you sanitize the data received, establish a connection with the DB (depends on DB type) then you can use standard SQL statements (INSERT INTO) to store it in the DB.
For something simple you don't even need to do that.
You can get free or cheap WebDAV hosting. This usually comes with a Web based "console" you can use to manage it and pull files off with.
Your program can be a WebDAV client and create and write files on the server, or append to existing files, read files, etc. No need for a database and no need to write any server-side logic at all. You can even map a drive letter to a WebDAV share in WinXP or later with no added software.
MyDrive offers a basic 2GB account for free. There are others out there too.
The ASP/PHP/CGI approach will work but it's more to do, more to support, etc. if your need is just remote storage.
There is no standard VB6 WebDAV client component but prior to Windows Vista you can use ADO objects since they can do it. Or you can write a little code to wrap around WinInet, XMLHTTPRequest, or WinHTTPRequest. Applying a little google will probably find you a number of 3rd party WebDAV client components too, though I don't know of a free one.
So i've been playing around with the code posted below, but it isn't working out. I don't get any error message, but the file doesn't get uploaded to mydrive storage site. o_O
Any ideas? ty!Code:Private Sub cmdTest_Click()
WebUploadFile "C:\test.txt", "http://webdav.mydrive.ch", "Uname", "Pword"
End Sub
Function WebUploadFile(file, url, user, pass)
Dim objXMLHTTP
Dim objADOStream
Dim arrbuffer
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.LoadFromFile file
arrbuffer = objADOStream.Read()
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.Open "PUT", url, False, user, pass
objXMLHTTP.send arrbuffer
objADOStream.flush
objADOStream.close
End Function
:rolleyes: Sorry, I didn't mean it was as trivial a process as that.
ADO can be used prior to a Vista update that breaks ADO WebDAV. But beyond that I don't know of anything built into Windows that will do the entire job unless you use the Redirector to map a drive letter.
If you need to do this based on a simple HTTPRequest object you have to do a little bit more work. WebDAV isn't HTTP, it's a protocol layer on top of HTTP. A simple PUT isn't going to cut it here.
I have attached a small demo project based on my own LittleDAV classes. They do not implement the whole protocol, but enough of it to be useful for many purposes. The demo does not include full error checking. If you just want to upload a text file you can strip out a lot of the code used in the Form. It probably isn't worth tampering with the classes much though.
You probably just need to set the three properties (BaseURL, User, PW) and then make one method call (PutFile).
You enter your settings in the top part of the form, and then Test them or Save them. If you Save a subsequent run will reload them from disk. I hate typing. The Base URL value designates the protocol (HTTP, HTTPS), the server, and any subfolder path you want to use ("test" here).
You can enter a disk file name and a name for the uploaded file. Upload uploads the file as a text/plain file. Directory lists the current directory on the WebDAV server. Delete deletes the file from the server (uses the name entered above).
Hey thank you very much for your help! I've been playing around with my code a bit more today and finally got it working the way i want!
Also thank you for posting your demo, it can help me understand the process a lot better!!! =)
Check it out though. If you upload using a plain PUT the server has to make a lot of assumptions about what you want it to do.