File size differences after copying a file to a server vÃ­a FTP
<p>I have created a PHP-script to update a webserver that is live inside a local directory.
I'm migrating the script into Python. It works fine for the most part, but after a PUT command the size of the file appears to change. Thus, the size of the file is different from that of the file on the server. </p>

<p>Once I download again the file from the FTP server, the only difference is the CR/LF mark. This annoys me because the same script is comparing the size of the files to update. Also, in case it means anything, the script works perfectly in PHP vÃ­a ftp_put.</p>

<pre><code>from ftplib import FTP

ftpserver = "myserver"
ftpuser = "myuser"
ftppass = "mypwd"

locfile =  "g:/test/style.css"
ftpfile =  "/temp/style.css"

try:
    ftp = FTP(ftpserver, ftpuser, ftppass)
except:
    exit ("Cannot connect")

f = open (locfile, "r")
try:
    ftp.delete (ftpfile)
except:
    pass

# ftp.sendcmd ("TYPE I")
# ftp.storlines("STOR %s" % ftpfile, f)
ftp.storbinary("STOR %s" % ftpfile, f)
f.close()

ftp.dir (ftpfile)
ftp.quit()
</code></pre>

<p>Any suggestions?</p>

<p>Do you need to open the locfile in binary using <code>rb</code>?</p>

<pre><code>f = open (locfile, "rb")
</code></pre>
