Search code examples
javascriptftpbinaryadobe-indesignextendscript

upload to ftp folder with indesign script


I am using indesign CC 2014 I have embedded "FTPConnection.jsx" that "Peter Torpey" wrote. then I wrote these codes to upload files to my server. Everything works fine, however files do not open correctly. I tried to open them with Notepad++ and I saw that while uploading files, the jsx changes them.

var ftp=new FTPConnection(false);
var acik=ftp.open("192.168.0.1","21","username","password");
if(acik==true){ftp.put(File(myFilePath),"images/1.png");}
ftp.close();

this is sample of original image:

‰PNG IHDR q Ò üÇF pHYs =5 =5ùäğ] IDATxÚìİ1¶«<£&è3OÁ#¨µ< <ç7òH+tÚ!Sğ*prà´C¦@ÒA‡»Ïù›ó—?~ÀHHì§ÖzÖ­{¿³÷! éEˆ_???¿ Ø6…
Ä @ˆ Ä @ˆ € @ˆ € ! € ! € !
B ! B „8 B „8 q „8 q „8 q â
q â Ä â Ä â Ä @ˆ
Ä•ïׯê·çoş—£2Ùõµ¡}úı¦p›Ød]ˆ=¶¥uÃ=ˆ½÷óúÇı6\V—Ş

this is after upload:

ıPNG

IHDR  q  ı   ııFı     pHYs  =5  =5ııı]    IDATxııı1ıı<ı&ı3Oı#ıı<ı

<ı7ıH+tı!Sı*prııCı@ıAııııııı?~ıHHııızıı{ııı! ıEı_???ı ı6ı
ı @ı ı @ı ı @ı ı ! ı ! ı !
B ! B ı8 B ı8 q ı8 q ı8 q ı
q ı ı ı ı ı ı @ı
ıııııııııoııı2ııııı}ıııpııd]ı=ııuı=ıııııııı6\Vıı


Solution

  • The first thing I'd recommend trying is to call

    ftp.setEncodingBinary();
    

    before the call to put().

    FTP supports two modes of transfer: ASCII and binary. In ASCII mode, the default, only seven bits per character are transmitted. This is sufficient for standard ASCII-encoded text files. For files with multi-byte encodings and for binary files, the binary FTP mode is required.