UploadFileToFTP Method (GdPictureImaging)
In This Topic
Uploads a specified file to a distant server using FTP transfer according to what you have specified.
Syntax
'Declaration
Public Function UploadFileToFTP( _
ByVal As String, _
ByVal As String, _
ByVal As String, _
ByVal As String, _
ByVal As String, _
ByVal As Integer _
) As GdPictureStatus
public GdPictureStatus UploadFileToFTP(
string ,
string ,
string ,
string ,
string ,
int
)
public function UploadFileToFTP(
: String;
: String;
: String;
: String;
: String;
: Integer
): GdPictureStatus;
public function UploadFileToFTP(
: String,
: String,
: String,
: String,
: String,
: int
) : GdPictureStatus;
public: GdPictureStatus UploadFileToFTP(
string* ,
string* ,
string* ,
string* ,
string* ,
int
)
public:
GdPictureStatus UploadFileToFTP(
String^ ,
String^ ,
String^ ,
String^ ,
String^ ,
int
)
Parameters
- FilePath
- The full file path of the file to upload, for example "d:/images/myimage.jpg".
- Host
- The host server name, for example "ftp.com".
- Path
- The full file path of the file to create on the distant server, for example "/demo/image.jpg".
- Login
- The user's login required to authenticate on the server.
- Password
- The user's password required to authenticate on the server.
- FTPPort
- The FTP port number used. It is usually 21.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
Uploading an image to a file located on a distant server using FTP transfer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Set the transferring options.
gdpictureImaging.SetFtpPassiveMode(true);
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.UploadFileToFTP(@"D:\images\image.jpg", "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Uploading failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Uploading using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Example
Uploading an image to a file located on a distant server using FTP transfer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Set the transferring options.
gdpictureImaging.SetFtpPassiveMode(true);
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.UploadFileToFTP(@"D:\images\image.jpg", "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Uploading failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Uploading using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
See Also