Yes I got the solution after few research.
Iam posting my solution for others .
import ftplib
import os
def upload(ftp, file):
ext = os.path.splitext(file)[1]
if ext in (".txt", ".htm", ".html"):
ftp.storlines("STOR flash " + file, open(file))
else:
print ftp.storbinary("STOR flash" + file, open(file, "rb"), 1024)
ftp = ftplib.FTP("**.**.**.**")
print ftp.login("ftp", "flash")
upload(ftp, "filename")