Here is the code.
- Code: Select all
filename = "./" + `random.randrange(0,9999999999999999999999999999999999)` + ".txt"
f = open(filename, 'w')
f = open(filename,'rb')
ftp = FTP('myftphost.com')
ftp.storbinary('STOR ``filename``', f )
Everything works as it is supposed to. The variable "filename" is saved in the current directory with the randomly generated name. When the ftp.storbinary command runs, it uploads the information in the file correctly, however, it always saves it with the name, `filename`. This causes it to overwrite itself each time that it uploads.
Basically, how can I get this to upload the file with the file's actual randomly generated name instead of "`filename`". Any advice would be very helpful, using storbinrary would be nice, but another command or even entire module is ok, as long as it solves my problem.
I've also posted this on Daniweb, so sorry if it looks familiar ;p