You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用批处理文件上传PNG文件后文件损坏,如何解决?

Fix Corrupted PNGs When Uploading via Batch FTP Script

Hey Thorsten,

Sorry to hear your PNG files are getting corrupted after uploading with your batch script—let’s get this sorted out quickly.

The root cause here is that FTP defaults to ASCII transfer mode, which automatically modifies characters like line breaks and carriage returns in your file. Since PNGs are binary files (not plain text), this character translation mangles the file structure and leads to corruption. The fix is simple: we just need to force FTP to use binary transfer mode.

Here’s your updated batch script with the critical addition:

@ECHO OFF
echo user MYUSERNAME>> ftpcmd.dat
echo MYPASSWORD>> ftpcmd.dat
echo binary>> ftpcmd.dat  :: This line enables binary transfer mode
echo put C:\1234.png>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat my-ftp-server.com
del ftpcmd.dat
goto Ende
:Ende
pause

What’s different?

We added the binary command right after logging into the FTP server. This tells the server to transfer the file as raw, unmodified binary data—no character translation, so your PNG stays intact.

Quick verification steps:

  1. After uploading, compare the file size of the remote PNG with your local 1234.png—they should be exactly the same if the transfer worked correctly.
  2. If you have a GUI FTP client handy, try manually uploading the PNG with binary mode enabled to confirm your server supports this (most standard FTP servers do).

That should fix the corruption issue entirely. Let me know if you hit any other bumps along the way!


内容的提问来源于stack exchange,提问作者user3322859

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:46:19