[Tutor] FTP Upload

dn PyTutor at DancesWithMice.info
Tue Jul 14 22:53:25 EDT 2020


On 15/07/20 6:15 AM, John Weller wrote:
> I have some graphs created with matplotlib which I need to upload to a web server.  I am using the command:
> 
> filename = 'mygraph.png'
> ftp.storbinary("STOR " + filename, open(filename, "rb"))
> 
> When I try to look at the graphs on the website they don't display and if I then download them to my PC using FileZilla and try to open them they are corrupt and show as Invalid Image.  If however I upload them manually using FileZilla they display correctly on the website.  I am obviously doing something wrong 😊  Advice please.


I've not tried the ftp library.
Remember that ftp can work in binary or text modes. Does the former need 
to be set, to avoid binary-file corruption?
-- 
Regards =dn


More information about the Tutor mailing list