通过可变路径上传

I'm trying to move uploaded files to nested folders with part of the path provided by a variable loaded from a form. As long as the variable contains just one folder, it works. It works if I load each folder into a separate variable too:

$one = "one" ;
$more = "more" ;
move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/$one/$more/$fileName");

I want the nested folders in one variable but it never works.

$thepath = $_POST["locate"]; //should be "one/more"
move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/$thepath/$fileName");

My guess is that it has something to do with the separators but I can't seem to find the solution.

You have a typo there (a blank space), change:

move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/$the path/$fileName");

to:

move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/$thepath/$fileName");