Line of server code to support PUTTING a file from a client to a server via TIdFTPServer

What is the server code needed in the StoreFile procedure to PUT a file from a client to an FTP Server?

Example code for GETTING a file is as follows (from previous postings):

procedure Form1.IdFTPServer1RetrieveFile(ASender: TidFTPServerThread; const AFileName: string; var VStream: TStream);
  VStream := TFileStrea.Create(AFileName, fmOpenRead);

But how do you implement a PUT on the server side?

I'm sure the solution is obvious.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Something like this: (code courtesy of Bas Gooijen)

function TForm1.TranslatePath(pfad: string): string;  
   i: integer;  
   for i:=0 to length(pfad) do  
      if pfad[i]='/' then pfad[i]:='\';  
   for i:=length(pfad)-1 downto 0 do  
   if pfad[i]='\' then  
   if copy(pfad,1,1)='\' then delete(pfad,1,1);  

procedure TForm1.IdFTPServer1StoreFile(ASender: TIdFTPServerThread; const AFilename: string; AAppend: Boolean; var VStream: TStream) ;  
  if FileExists(translatepath(AFilename, ASender.HomeDir)) and AAppend then  
    VStream := TFileStream.create( translatepath( AFilename, ASender.HomeDir ) , fmOpenWrite or fmShareExclusive ) ;  
    VStream.Seek( 0, soFromEnd ) ;  
    VStream := TFileStream.create( translatepath( AFilename, ASender.HomeDir ) , fmCreate or fmShareExclusive ) ;  

RoyMakruckiAuthor Commented:
This will create a file on the server, but then I must read from the client data stream and write this to the new file on the server.  How do I do that?  

Thanks for your help
Well, interestingly, that's all that you need to do... you created the TFileStream, remember? As data is read, the component will now automatically use the FileStream you created, and save to it... cool huh ;-)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RoyMakruckiAuthor Commented:
Yes, I understand, and it works as you said.  Thanks for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.