我需要在主机上更新我的counter.txt文件。
我正在使用我在此处找到的一些代码:How to download a file with progress with IdHTTP via https,稍加修改。
发布不会更新文件。 Put得到405错误方法不允许。
有人请回顾一下,并指出为什么不更新柜台?
计数器文件位于:aFileURL ='http://greatdaydan.com/Counter.txt';
procedure TIdHTTPProgress.DownloadFile(const aFileUrl: string; const aDestinationFile: String);
var
LDestStream: TFileStream;
aPath: String;
begin
Progress := 0;
FBytesToTransfer := 0;
aPath := ExtractFilePath(aDestinationFile);
if aPath <> '' then
ForceDirectories(aPath);
LDestStream := TFileStream.Create(aDestinationFile, fmCreate);
try
Get(aFileUrl, LDestStream);
finally
FreeAndNil(LDestStream);
end;
FFinished := True;
end;
procedure TIdHTTPProgress.UploadFile(const aFileUrl, aDestinationFile: String);
var
fs: TFileStream;
Response: TStringStream;
Reply: String;
begin
fs := TFileStream.Create(aDestinationFile, fmOpenRead or fmShareDenyWrite);
Response := TStringStream.Create;
try
post(aFileUrl, fs, Response);
Reply := Response.DataString
finally
FreeAndNil(fs);
Response.Free;
end;
FFinished := True;
end;