簡體   English   中英

php-如何將文件移動到使用userid創建的文件夾(上傳文件)

[英]php-how to move files to the folder created using userid (upload files)

上傳后,我將根據唯一的Application ID創建文件夾。

我在這里面臨的問題是,一旦我上載,文件就會從相應的文件夾中上載。

甚至創建文件夾。

任何人都可以幫忙!!!

$path = $file['name'];
$path_user = '/home/devestctrl/public_html/wp-content/plugins/est_collaboration/Files/'.'/'.$send_id;
if (!file_exists($path_user)) {
    if (mkdir( $path_user,0766,false )) {
        if (move_uploaded_file($file['tmp_name'],$path_user.$path)) {
            echo"inside 2"."<br>";
            echo"Your File Successfully Uploaded";
        }                 
    }
}

刪除多余/est_collaboration/Files/'.$send_id

最后追加/ 喜歡

$path_user = '/home/devestctrl/public_html/wp-content/plugins/est_collaboration/Files/'.$send_id.'/';

您需要在$path_user$path之間添加一個斜杠:

$path_user = '/home/devestctrl/public_html/wp-content/plugins/est_collaboration/Files/'.'/'.$send_id;
if (!is_dir($path_user)) {
    if (!mkdir($path_user, 0766, false)) {
        die('Directory cannot be created'); // handle this exception
    }
}

if (move_uploaded_file($file['tmp_name'], $path_user . '/' . $path)) {
// ----- You are missing this slash -------------------^^^------------
    echo "inside 2"."<br>";
    echo "Your File Successfully Uploaded";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM