Dart Ftp Control
Put Method
Specifies the Universal Resource Locator. This parameter is modeled after IE 4.0.
Optional. Specifies the source (local) file name, or a String, Byte array, or DartStream object that is filled with file data. If not specified or NULL, the filename from the URL (without path) is opened in the local default directory.  If Type is ftpZip the file or files will be compressed and stored on the remote directory with the name specified in the URL parameter plus the .zip extension. When using ftpZip, Source is not optional.
Optional. Specifies the number of characters in the source file that should be skipped. If not specified or 0, the entire file is transferred. If a file transfer was previously interrupted, the Marker parameter can be used to start at an exact location, so the entire file does not have to be transferred. When specified, the ftpAppend command is used, so the application must know the amount of data that has already transferred. If Source is a String or Byte array, then the entire contents is appended to the destination file.
Optional. Use in conjunction with Marker to specify the number of bytes to be skipped in a large file. If a file transfer was previously interrupted, Marker and MarkerHigh can be used to start at an exact location greater than 2^31.
Description
Login, store a file, and logout in one easy step.
Syntax
Visual Basic
Public Sub Put( _
   ByVal Url As String, _
   Optional ByVal Source As Variant, _
   Optional ByVal Marker As Long = 0, _
   Optional ByVal MarkerHigh As Long = 0 _
) 
Parameters
Url
Specifies the Universal Resource Locator. This parameter is modeled after IE 4.0.
Source
Optional. Specifies the source (local) file name, or a String, Byte array, or DartStream object that is filled with file data. If not specified or NULL, the filename from the URL (without path) is opened in the local default directory.  If Type is ftpZip the file or files will be compressed and stored on the remote directory with the name specified in the URL parameter plus the .zip extension. When using ftpZip, Source is not optional.
Marker
Optional. Specifies the number of characters in the source file that should be skipped. If not specified or 0, the entire file is transferred. If a file transfer was previously interrupted, the Marker parameter can be used to start at an exact location, so the entire file does not have to be transferred. When specified, the ftpAppend command is used, so the application must know the amount of data that has already transferred. If Source is a String or Byte array, then the entire contents is appended to the destination file.
MarkerHigh
Optional. Use in conjunction with Marker to specify the number of bytes to be skipped in a large file. If a file transfer was previously interrupted, Marker and MarkerHigh can be used to start at an exact location greater than 2^31.
Remarks

Note  Only UNIX-style file systems are supported by this method (forward slashes specify the file path).

This method establishes a connection and if necessary, sequences the following commands (refer to the CommandConstants topic for more information on these commands):

URL format (note that file path is relative to the root directory):

ftp://username:password@hostname:port/filepath

"ftp://" is optional, and can be omitted

"username:password@", if omitted, defaults to "anonymous:powertcp@"

":port", if omitted, defaults to "21"

Always blocks until complete or throws an error. Progress and Progress64 events fire as each buffer is sent and any reply is received.

If Type is ftpZip the file or files specified in Source will be automatically compressed and transferred to the remote directory and file name identified in the URL. The URL must contain the name of the remote file. The file placed on the remote server will have an extension of .zip. The Source parameter is not optional if the ftpZip type is used. For more advanced zip functionality, please look at PowerTCP Zip Compression for ActiveX at www.dart.com.

MarkerHigh should be set to the value of the restart position divided by 2^31 (2147483648). Marker should be set to the remainder of this operation.

A ptInvalidParam2 error will occur if the size of the source data is larger than 2^31 and is NOT a file.

If you wish to use a DartStream object as Result, you must first add a reference to Dart FTP Utils.

Error Codes

This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):

Example
This example demonstrates using the Put method to store a file and a sting in one line of code each.
Private Sub Command1_Click()
	On Error Goto OnError ' use intrinsic error handling
	Dim FileBuf As String ' local scope allowed because Timeout > 0
	' Login to the user account and store File.txt
	Ftp1.Put "ftp://user:password@ftp.dart.com/users/user/File.txt", "c:\File.txt"
	Exit Sub
OnError: ' Any error jumps here
	Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description
End Sub
This example demonstrates using the Put method to login, zip a file, and store the file in one line of code.
Private Sub Command1_Click()
	On Error Goto OnError
	' Set Type to ftpZip, this will cause the file to be automatically zipped 
	' before storing
	Ftp1.Type = ftpZip
	' Login, zip, and store a file in one step
	Ftp1.Put "ftp://user:pass@myserver/home/zippedfile.zip", "c:\test.txt"
	Exit Sub
OnError:
	Debug.Print Err.Description
End Sub
See Also

Ftp Object  | Ftp Members


PowerTCP SSL for ActiveX Documentation Version 2.2.1
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic