Вопрос

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

Это было полезно?

Решение

That's because ftp.storlines() is sending the file in ascii mode, you should use ftp.storbinary() for an image file (binary mode):

    F=open("Simple.png","rb")
    ftp.storbinary('STOR image.png',F,1024)

Другие советы

Try using storbinary()...

Because it takes the binary values of that image... So that no pixel values are messed up...

Since image files contain pixels... Need to store the exact X,Y positions of the pixels.

So storbinary() does that by default.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top