我想做一个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