|
-
Feb 7th, 2007, 11:37 PM
#1
Thread Starter
Junior Member
Automatically uploading a file to a server
I'm new to server management. 1) What is the VB code to automatically upload a file, such as the results of a test, to a web server online? 2) What must I do and have on my web server to get this to work?
Here's some code I found that I think will do the trick. I want the user to click a Submit button so it submits the results of a quiz to the WEb server:
Will this work in 6.0? From: http://support.softartisans.com/docs...g_simplevb.htm
A Simple Visual Basic Upload
To use XFile from Visual Basic, add XFile to your list of VB references.
Exercise 3: A Simple Visual Basic Upload
1. Create a new, standard, Visual Basic project.
2. Open the Project menu, select References, and check "SAXFile 1.0 Type Library".
3. Create a command button on your form, name it cmdSendFiles, and give it an appropriate caption (such as, "Upload").
4. Enter the following code in the code section of your form.
Private Sub cmdSendFiles_Click()
'--- Create an instance of the XFRequest object, XFile's principal object
Set XFile = New XFRequest
'--- Set the Server to which you are uploading
XFile.Server = "localhost"
'--- Set the specific script to which you are uploading
XFile.ObjectName = "/SAXFileSamples/asp/post/onefile/formresp.asp"
'--- Set a file to upload
XFile.AddFile "C:\boot.ini", "File1"
'--- Begin transferring the files
XFile.Start
'--- Destroy the XFRequest Object
Set XFile = Nothing
End Sub
5. Run the project and click on the upload button. Boot.ini will be uploaded to the local server.
Understanding the Script
* Set XFile = New XFRequest creates an instance of the XFRequest object. XFRequest is XFile's principal object. XFRequest sends the HTTP request (Get, Post, or Put) to the server.
* SAXFile.Server sets the domain to which the file will be posted. In this example we use "localhost." If we were posting through the Internet, we would use the format "www.domain.com."
* SAXFile.ObjectName specifies the exact page to which our request will be posted. In this case, it is formresp.asp, located in /saxfilesamples/asp/post/onefile. Formresp.asp uses SoftArtisans FileUp to process the upload.
* SAXFile.AddFile presets a file to upload. Addfile takes two parameters: the path and file name on the client, and an item name for reference to the file on the server.
* SAXFile.Start initiates the file transfer.
* Set XFile = Nothing destroys the project's instance of the XFRequest object. This prevents draining of your resources.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|