문제

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