BOOL
WINAPI PutFtpFile( HWND hDlg, HINTERNET hConnection,
int nFtpFileNameId, int nLocalFileNameId )
{
TCHAR szFtpFileName[FTP_FUNCTIONS_BUFFER_SIZE];
TCHAR szLocalFileName[FTP_FUNCTIONS_BUFFER_SIZE];
DWORD dwTransferType;
TCHAR szBoxTitle[] = TEXT( "Upload
FTP File" );
TCHAR szASCIIQuery[] =
TEXT("Do you want to upload as
ASCII text? (Default is binary)");
TCHAR szAsciiDone[] =
TEXT( "
ASCII Transfer completed successfully..." );
TCHAR szBinaryDone[] =
TEXT( "Binary Transfer completed successfully..." );
if( !GetDlgItemText( hDlg, nFtpFileNameId, szFtpFileName,
FTP_FUNCTIONS_BUFFER_SIZE ) ||
!GetDlgItemText( hDlg, nLocalFileNameId, szLocalFileName,
FTP_FUNCTIONS_BUFFER_SIZE ) )
{
MessageBox( hDlg,
TEXT("Target File or Destination File Missing"),
szBoxTitle,
MB_OK | MB_ICONERROR );
return( FALSE );
}
dwTransferType =
( MessageBox( hDlg,
szASCIIQuery,
szBoxTitle,
MB_YESNO ) == IDYES ) ?
FTP_TRANSFER_TYPE_ASCII : FTP_TRANSFER_TYPE_BINARY;
if( !FtpPutFile( hConnection,
szLocalFileName,
szFtpFileName,
dwTransferType,
0 ) )
{
InternetErrorOut( hDlg, GetLastError( ), TEXT( "FtpGetFile" ) );
return( FALSE );
}
MessageBox( hDlg,
( dwTransferType == FTP_TRANSFER_TYPE_ASCII ) ?
szAsciiDone : szBinaryDone, szBoxTitle, MB_OK );
return( TRUE ); // Remember to refresh directory listing
}