The AddConnection method makes a connection to a network resource. You can use it to connect remote computer and store uploaded files on network drives.
ASPForm.AddConnection (RemoteName as String, UserName as String, Password as String)
| Where | Type | Optional | Default | Description |
|---|---|---|---|---|
| RemoteName | String | Network device name, specifies the network resource to connect to. | ||
| UserName | String | Specifies a user name to be used in making the connection | ||
| Password | String | Specifies a password to be used in making the network connection |
This method calls WNetAddConnection2 API function.
ASP - upload and store files to a network drive |
| You can store uploaded files also to a network disk or network resource. The main problem within this task are user rights. The default user account running ASP script (usually IUSR_COMPUTERNAME) has no access to network resources. One of the way is to connect to a network resource with another Username and Password (using AddConnection), store uploaded files and Disconnect from the resource (CancelConnection). This is a sample VBScript concept of the task. See upload-network.asp sample for full code. |
'Create ASPForm object
Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'was the Form successfully received?
If Form.State = 0 Then 'completed
'Connect to a network resource using username and password
Form.AddConnection "\\servername\sharename", "administrator", "password"
'Save uploaded files to the network disk
Form.Files.Save "\\servername\sharename\folder"
'You can disconnect the network resource here.
Form.CancelConnection "\\servername\sharename"
End If |
AddConnection, CancelConnection, CheckRequirements, Read, Sleep, StringToBinary
BytesRead, Files, FormType, getForm, CharSet, ChunkReadSize, Items, MaxMemoryStorage, NewUploadID, ReadTime, ReadTimeout, SizeLimit, SourceData, State, TempPath, Texts, ThreadPriority, TotalBytes, UploadID
The ASPForm collection retrieves the values of form elements posted to ASP script by a form using the POST method. ASPForm can process multipart/form-data or application/x-www-form-urlencoded data with length up to 2GB.
© 1996 - 2009 Antonin Foller, Motobit Software | About, Contacts | e-mail: info@pstruh.cz