title: Indy upload Memorystream to FTP
body: <p>I generate a JPEG at runtime, from a Screenshot, and want to upload it to a FTP server. But when I have it is uploaded it is no longer a valid jpeg.</p>
  
  <p>In this example I just load a bitmap from the HD:</p>
  
  <p>First some code:</p>
  
  <pre><code>procedure TForm13.Button1Click(Sender: TObject);
  var
    InBitmap: TBitmap;
    JpegImage: TJpegImage;
    MemoryStream: TMemoryStream;
    IdFTP: TIdFTP;
  begin
    InBitmap := TBitmap.Create;
    MemoryStream := TMemoryStream.Create;
    JpegImage := TJpegImage.Create;
    IdFTP := TIdFTP.Create(self);
  
    try
      InBitmap.LoadFromFile('C:\aa\test.bmp');
  
      JpegImage.Assign(InBitmap);
      JpegImage.CompressionQuality := 65;
      JpegImage.SaveToStream(MemoryStream);
  
      with IdFTP do
        try
          Host := &lt;HOST&gt;;
          Username := &lt;USER&gt;;
          Password := &lt;PASS&gt;;
          Port := 21;
          Passive := True;
          Connect;
          MemoryStream.Position := 0;
          Put(MemoryStream, 'test.jpg');
        finally
          Disconnect;
        end;    
    finally
      IdFTP.Free;
      JpegImage.Free;
      InBitmap.Free;
      MemoryStream.Free;
    end;
  end;
  </code></pre>
  
  <p>I have tried to save the JPEG to file before uploading it, and it is a valid JPG</p>
  
  <p>I have tried to save the MemortStream to a file before uploading it, and it is a valid JPG</p>
  
  <p>But when it is uploaded to the FTP server it is just a blank JPG file, still "valid" though.</p>
  
  <p>It is not my FTP server, but one owned by those who host my domain. Here is a link to the just uploaded jpg: <a href="http://fluffykids.dk/test.jpg" rel="nofollow">http://fluffykids.dk/test.jpg</a> and here is the jpeg I saved to disc : <a href="http://fluffykids.dk/aa.jpg" rel="nofollow">http://fluffykids.dk/aa.jpg</a>. </p>
  
  <p>Question: Why am I loosing the "content" of my JPEG after uploading it?</p>