我用delphi 自带ftp上传文件为啥只能上传英文文件名的资料

yanfeishen79 2008-09-04 10:11:49
我用delphi 自带ftp上传文件为啥只能上传英文文件名的资料
ftp.put(PChar(opendialog1.FileName),filename,FALSE);
上传中文文件名的的就会提示Project GreenOA.exe raised exception class EIdProtocolReplyError with message '/??.doc: Cannot create file错误。
...全文
349 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinawcs 2008-09-05
  • 打赏
  • 举报
回复
把你的 文件目录名+文件名 贴出来

我的 ics ftp 上传线程部分代码(仅供参考) 没有问题的


unit FtpPut;

interface

uses
Classes,UMirrorSend,dialogs,SysUtils,idftp;

type
ftpThd = class(TThread)
private
{ Private declarations }
CreateFileName:String;
ProName:String;
protected
procedure Execute; override;
public
constructor Create(StreamFile:String;FilesName:String);
procedure putfile;
end;

implementation

uses Math;

{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,

Synchronize(UpdateCaption);

and UpdateCaption could look like,

procedure ftp3.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }

{ ftp3 }

constructor ftpThd.Create(StreamFile:String;FilesName:String);
begin
CreateFileName :=StreamFile ;
ProName :=FilesName ;

FreeOnTerminate := True;
inherited Create(False);
end;

procedure ftpThd.Execute;
var
fstream: TFileStream ;


begin
try
fstream := TFileStream.Create(CreateFileName,fmOpenRead);
except
//ShowMessage('读取文件出错');
Abort;
end;

{ if not Form1.IdFTP2.Connected then
begin
ShowMessage('err');
fstream.Free;
end;}

try
{ftp1:=TIdFTP.Create(nil);
with ftp1 do
begin
Host :='124.0.0.188';
Port :=23;
Username :='system';
Password :='system';
Connect();
end;}

frmMirrorSend.ftpClient.put(fstream,ProName ,False );

Synchronize(putfile );
finally
fstream.Free;
Terminate ;

end;
{ Place thread code here }
end;

procedure ftpThd.putfile;
begin

//frmMirrorSend.ggFileSend.Progress :=0;
ShowMessage('上传完毕111!');
//frmMirrorSend.lvFileList.Items[2].Caption := '已发送';
{ Place thread code here }
end;

end.




pengxuan 2008-09-05
  • 打赏
  • 举报
回复
换台电脑试试
yanfeishen79 2008-09-05
  • 打赏
  • 举报
回复
上传文件的 目录是C:\Documents and Settings\syf\My Documents\厦门东通道维护制度.doc'
chinawcs 2008-09-04
  • 打赏
  • 举报
回复
文件目录中 不能有 空格 如 : c:\123 456\xx.iso

最好用 ics 控件做个 ftp 简单稳定 不用 indy

另外 当文件大小超过 2G时 就不能上传了 需要该 原代码

lyguo 2008-09-04
  • 打赏
  • 举报
回复
用INDY 中的试一下,
目录不要太长,另外不要有太多的其它字符,如:空格 括号等。
yanfeishen79 2008-09-04
  • 打赏
  • 举报
回复
那要怎么解决?
xabcxyz 2008-09-04
  • 打赏
  • 举报
回复
没有试,从现象猜测是字符集问题,internet的7bit字符集和GB字符集传输出错了.
yanfeishen79 2008-09-04
  • 打赏
  • 举报
回复
还是不行,我用ics写的也是有我问题。。
if ftp1.Connected then ftp1.Quit;
ftp1.Username:='greenway';
ftp1.Passive:=true;

ftp1.password:='';
ftp1.hostname:=';
ftp1.Connect;
if ftp1.Connected=true then
begin
ftp1.LocalFileName:=filedir+filename;
Ftp1.HostFileName:=filename;
ftp1.Put;
end;
这样写好像也是有问题,传上去的文件只有扩展名。。。

5,929

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧