我用WIN32 INTERNET API实现ftp上传文件,提示可以连接服务器,但无法上传文件,用cuteftp等软件,或者用idftp组件在同一机器上上传都没有问题,这是怎么回事?代码如下:var
RemoteFile: String ;
LocalFile: String ;
sFile: String ;
FTPPath: String ;
i: integer ;
blnReturn: boolean ;
dwInternetFlags: DWORD ;
begin
if (hConnect <> nil) then
begin
FTPPath := GetFTPDirectory(hConnect) ;
SFILE(要上传的文件名)
LocalFile := localDir + sFile ;
RemoteFile := FTPPath + sFile ;
StatusBar1.Panels[0].Text := 'Uploading' ;
blnReturn := FtpPutFile(hConnect,
pchar(LocalFile),
pchar(RemoteFile),
dwInternetFlags,
$0) ;
end ;
end ;
end; 单步执行,到FtpPutFile这一步返回值是false,难道上传有时间限制?不能超时?哪里可以修改这个参数?
RemoteFile: String ;
LocalFile: String ;
sFile: String ;
FTPPath: String ;
i: integer ;
blnReturn: boolean ;
dwInternetFlags: DWORD ;
begin
if (hConnect <> nil) then
begin
FTPPath := GetFTPDirectory(hConnect) ;
SFILE(要上传的文件名)
LocalFile := localDir + sFile ;
RemoteFile := FTPPath + sFile ;
StatusBar1.Panels[0].Text := 'Uploading' ;
blnReturn := FtpPutFile(hConnect,
pchar(LocalFile),
pchar(RemoteFile),
dwInternetFlags,
$0) ;
end ;
end ;
end; 单步执行,到FtpPutFile这一步返回值是false,难道上传有时间限制?不能超时?哪里可以修改这个参数?
解决方案 »
- TDBGrid数据中某个或者几个字段值,如何同时post到两个数据表?
- 十六进制转十进制问题?
- TImage的Canvas的问题???
- 大家认为together for delphi什么时候会出?欢迎讨论,人人有分
- 难道TREEVIEW不能有CheckBoxes吗?
- 请问我想让dbgrid控件的第一列可以实现下拉框,以选择类型,如何实现?
- 怎么实现控制面板当中的添加windows组件功能!!!是哪个api函数
- 利用socket控件来传送文件是不是有大小限制?
- ado远程操作数据库,速度怎么那么慢??????
- 输入出现的问题,请进:)
- FastReport 如何封装成DLL供VB6、PB等调用
- 怎么实现用户登陆后能使用自己的信息?
function PutFTPFile(const PutFile, Host, UserName, Password, Dir, RemoteFile:
PChar;
Port: Word;): Boolean;
var
H, FTP: HINTERNET;
H1: Hwnd;
begin
Result := False;
H := InternetOpen(nil, INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if H = nil then Exit;
try
FTP := InternetConnect(H, Host, Port, UserName, Password,
INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0); if FTP = nil then Exit;
try
if (Dir = nil) or FtpSetCurrentDirectory(FTP, Dir) then
begin
Result := FtpPutFile(FTP, RemoteFile, SaveFile, False, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0);
end;
finally
InternetCloseHandle(FTP);
end;
finally
InternetCloseHandle(H);
end;end;
刚刚写的,没测试