0

I'm using this command to ftp upload a png image. But when I upload the image is not visible it looks like currupted even if I download it I can't view the image. Here is the code

ftp.storlines('STOR ' + 'Simple.png', open('Simple.png', 'rb'))

here is the uploaded file http://llgrow.co.nf/Simple.png

4

2 回答 2

0

尝试使用 storbinary()...

因为它采用该图像的二进制值......所以没有像素值被弄乱......

由于图像文件包含像素...需要存储像素的确切 X、Y 位置。

所以 storbinary() 默认情况下会这样做。

于 2012-12-27T20:09:20.027 回答
0

那是因为ftp.storlines()以 ascii 模式发送文件,您应该使用ftp.storbinary()图像文件(二进制模式):

    F=open("Simple.png","rb")
    ftp.storbinary('STOR image.png',F,1024)
于 2012-12-27T19:56:45.970 回答