Why do I get this IOerror13 ? Using python
Question: 
    import sys
    import os
    import re
    import ftplib
    
    os.system('dir /S "D:\LifeFrame\*.jpg" > "D:\Python\placestogo.txt"')   #this is where to search.
    dat = open('placestogo.txt','r').read()
    
    drives = re.findall(r'.\:\\.+.+',dat)
    for i in range(len(drives)):
        path = drives[i]
        os.system('dir '+ path +'\*.jpg > D:\python\picplace.txt')
        picplace = open('picplace.txt','r').read()
        pics = re.findall(r'\w+_\w+.\w+..jpg|IMG.+|\w+.jpg',picplace)
        for i in range(len(pics)):
            filename = pics[i]
            ftp = ftplib.FTP("localhost")
            print ftp.login("xxxxxxxx","xxxxxxxx")
            ftp.cwd("/folder")
            myfile = open(path,"rb")
            print ftp.storlines('STOR ' + filename, myfile)
            print ftp.quit()
            sys.exit()
    

i am trying to copy all of those files to my ftp server but it gives me that
error:

    
    
    d:\Python>stealerupload.py
    230 Logged on
     Traceback (most recent call last):
      File "D:\Python\stealerupload.py", line 22, in <module>
        myfile = open(path,"rb")
    IOError: [Errno 22] invalid mode ('rb') or filename: '"D:\\LifeFrame"'
    

any one knows where is the problem ? I am running as administrator and folder
should have permissions


Answer: In the error message, it shows `'"D:\\LifeFrame"'`, which to me looks like you
have extra quotes in `path`. Try adding `print path` to see what its value is.

Maybe you want to upload data from `filename` to your server, not from `path`,
in which case Python showed in the error message is where the bug is: you
should be opening `filename` instead.

