1

I'm trying to upload an image via TIdFtp from Delphi, but some part of the uploaded image is white. The uploaded image is like below:

enter image description here

TransferType is set to ftBinary. I think it's not related to image size because I tried with different images with different sizes. Also, I tried with and without compressing JPG too.

The source code is written in this way:

var
JPG: TJPEGImage;
begin
JPG := TJPEGImage.Create;
JPG.Assign(Image1.Picture.Bitmap);
MS := TMemoryStream.Create;
JPG.SaveToStream(MS);
IdFTP1.Connect;
IdFTP1.Put(MS, strFileName);
IdFTP1.Disconnect;
end

Additional information

The log file of upload process is like below:

Stat Connected.
Recv 21/09/2023 20:00:32: 220 ProFTPD Server (ProFTPD) [**********]<EOL>
Sent 21/09/2023 20:00:32: HOST ***********<EOL>
Recv 21/09/2023 20:00:32: 504 ftp.*********: Unknown hostname provided<EOL>
Sent 21/09/2023 20:00:32: USER ********<EOL>
Recv 21/09/2023 20:00:32: 331 Password required for ******<EOL>
Sent 21/09/2023 20:00:32: PASS *********<EOL>
Recv 21/09/2023 20:00:32: 230 User *********** logged in<EOL>
Sent 21/09/2023 20:00:32: FEAT<EOL>
Recv 21/09/2023 20:00:32: 211-Features:<EOL>
Recv 21/09/2023 20:00:32:  AUTH TLS<EOL> CCC<EOL> CLNT<EOL> CSID<EOL> EPRT<EOL>
Recv 21/09/2023 20:00:32:  EPSV<EOL> HOST<EOL> LANG en-US.UTF-8*<EOL> MDTM<EOL> MFF modify;UNIX.group;UNIX.mode;<EOL> MFMT<EOL> MLST modify*;perm*;size*;type*;unique*;UNIX.group*;UNIX.groupname*;UNIX.mode*;UNIX.owner*;UNIX.ownername*;<EOL> PBSZ<EOL> PROT<EOL> RANG STREAM<EOL> REST STREAM<EOL> SIZE<EOL> SSCN<EOL> TVFS<EOL> UTF8<EOL>211 End<EOL>
Sent 21/09/2023 20:00:32: CLNT Indy 10.6.2.5341<EOL>
Recv 21/09/2023 20:00:32: 200 OK<EOL>
Sent 21/09/2023 20:00:32: TYPE I<EOL>
Recv 21/09/2023 20:00:32: 200 Type set to I<EOL>
Sent 21/09/2023 20:00:32: SYST<EOL>
Recv 21/09/2023 20:00:32: 215 UNIX Type: L8<EOL>
Sent 21/09/2023 20:00:32: TYPE I<EOL>
Recv 21/09/2023 20:00:32: 200 Type set to I<EOL>
Sent 21/09/2023 20:00:32: PASV<EOL>
Recv 21/09/2023 20:00:32: 227 Entering Passive Mode *******,246,62).<EOL>
Sent 21/09/2023 20:00:32: STOR ZZP7nY.jpg<EOL>
Recv 21/09/2023 20:00:32: 150 Opening BINARY mode data connection for ZZP7nY.jpg<EOL>
11
  • See stackoverflow.com/questions/29673891/… for an example
    – mjn
    Sep 21 at 15:11
  • @MartinPrikryl I tried it but the problem continues. Sep 21 at 15:20
  • @mjn All properties of Indyftp is like the example you mentioned and the codes are the same, but the problem is exists. Sep 21 at 15:21
  • 1
    Can you upload the same image file correctly using GUI/commandline FTP client running on the same machine, where your application fails to do so? Sep 21 at 15:41
  • 2
    @MartinPrikryl it is not necessary to set MS.Position=0 as TIdFTP.Put() will automatically upload a TStream from Position=0 by default. There are optional parameters to change that behavior when needed (ie, for resuming broken uploads, etc) Sep 21 at 17:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.