我想做一個PHP上傳,將上傳到特定的文件夾。 一個人會選擇他們希望上傳的文件旁邊的下拉框,這是一個文件夾列表。這是因爲它組織文件。PHP上傳到特定文件夾
<?php
session_start();
if(!isset($_SESSION["USER"]["Admin"])){
header("Location: index.html?unath");
}
$folder = mysql_real_escape_string($_POST['loc']);
$target_path = "../../shared/docs/$folder";
$upload2 = $target_path . basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $upload2)) {
echo "The file ". basename($_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
目前代碼上傳文件到「文檔」文件夾而不是文檔/文件夾。相反,它將文件夾名稱放在文件的前面。對於示例 - 如果文件夾名爲「ABC」和我的文件名爲robs.docx將其上傳到主文檔文件夾中,並調用它abcrobs.docx
我看到我現在出了問題..小白錯誤:)感謝的是:d – Rsmithy
我會,但我要等到計算器讓我 – Rsmithy