سؤال

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