I need to move uploaded files into a subfolder where the subfolder is created at the time of upload using mkdir
.
I currently have this code:
if($_FILES['updfile']['tm开发者_Go百科p_name'] != '')
{
$destd = mkdir($_SERVER['DOCUMENT_ROOT'] . "/pms/upload_files/project_" . $id, 0777);
$source = $_FILES['updfile']['tmp_name'];
$dest = $_SERVER['DOCUMENT_ROOT'] . "/pms/upload_files/" . $destd;
//echo $dest; exit;
$ext = strstr($_FILES['updfile']['name'], ".");
$imageName = $_FILES['updfile']['name'];
$destination = $dest.$imageName;
//print_r($source);exit;
move_uploaded_file($source, $destination);
}
The problem I'm having is that the above code only creates the folder - it doesn't upload the file into that folder. What am I doing wrong?
This is the correct location based on your code:
$dest=$_SERVER['DOCUMENT_ROOT']."/pms/upload_files/project_".$id."/";
$destination = $dest.$imageName;
精彩评论