Question

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

Was it helpful?

Solution

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)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top