Hey guys, I'm making a CMS for my website with python.
I was wondering if anybody could give me some insight on (perhaps) an OS function that will copy a file from one folder and 'paste' it in another. thanks!:cheesy:

Alright...I couldn't find anything as far as the os module I tried this but I still couldn't get it to work:

import shutil
shutil.copy("hipgamer/list.htm", "ftp://hipgamer@64.139.104.222") 
 
 
Traceback (most recent call last):
  File "hipgamer/transfer.py", line 3, in <module>
    shutil.copy("hipgamer/list.htm", "ftp://64.139.104.222")
  File "C:\Python25\lib\shutil.py", line 80, in copy
    copyfile(src, dst)
  File "C:\Python25\lib\shutil.py", line 47, in copyfile
    fdst = open(dst, 'wb')
IOError: [Errno 2] No such file or directory: 'ftp://64.139.104.222'

So it worked fine with a normal folder, but I couldn't get it to upload to the FTP (understandable)
any input would be great, thanks!

Alright, I figured out how to do it, did some more research and stumbled on the answer

import ftplib                                          # We import the FTP module
session = ftplib.FTP('myserver.com','login','passord') # Connect to the FTP server
myfile = open('toto.txt','rb')                         # Open the file to send
session.storbinary('STOR toto.txt', myfile)            # Send the file
myfile.close()                                         # Close the file
session.quit()                                         # Close FTP session

hopefully somebody may find this useful. the site i found this at was:
http://sebsauvage.net/python/snyppets/

Alright, I figured out how to do it, did some more research and stumbled on the answer

import ftplib                                          # We import the FTP module
session = ftplib.FTP('myserver.com','login','passord') # Connect to the FTP server
myfile = open('toto.txt','rb')                         # Open the file to send
session.storbinary('STOR toto.txt', myfile)            # Send the file
myfile.close()                                         # Close the file
session.quit()                                         # Close FTP session

hopefully somebody may find this useful. the site i found this at was:
http://sebsauvage.net/python/snyppets/

Hey DarkFkash, greate Python site!!! Thanks!

Used Reply with Quote, but it came up empty.
Anyway DarkFlash, thanks for the great Python site!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.