开发者

Upload file in subfolder using move_uploaded_file in php?

开发者 https://www.devze.com 2023-04-11 02:28 出处:网络
I need to move uploaded files into a subfolder where the subfolder is created at the time of upload using mkdir.

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消