Basically I am scanning whole system using python directory listing technique and sending all files to PHP script from where I want to store them in a folder named as project on my computer. I saw available solution of my problem but these solutions are not working for me.
How to upload & Save Files with Desired name
my python script:
url = 'http://localhost:9090/project/php/test.php'
driveStr = subprocess.check_output("fsutil fsinfo drives")
driveStr = driveStr.decode("utf-8")
driveStr = driveStr.strip().lstrip('Drives: ')
drives = driveStr.split()
print(drives)
mylist = []
for drive in drives:
if os.path.isdir(drive):
p = os.walk(drive)
for i, dirs, files in p:
for filename in files:
if not filename.endswith ( ".txt" ) :
continue
print ( filename )
post = { 'filename' : filename }
req = urlencode ( post ).encode ( "utf-8" )
req = requests.post ( url , post )
I am scanning whole system for text files and sending these files to PHP script on server.
my PHP script:
if(isset($_POST['filename']))
{
$file = $_POST['filename'];
$dir = "C:\wamp64\www\project";
move_uploaded_file($file, $dir);
}
It is not storing those file into target directories. But when I saved them in any file on computer those files successfully saved but I am unable to store them in a directory.