我正在尝试以特定路径上传文件,很遗憾,有2条警告阻止我完成上传:/
mkdir():
中没有此类文件或目录move_uploaded_file(Candidatures / xxxx / index.jpeg):无法打开流:
我做错了什么?
$uploadState = "";
if(!empty($_FILES['upload_CoveringLetter']))
{
$uploadState = 1;
$file_name = $_FILES['upload_CoveringLetter']['name'];
$file_size = $_FILES['upload_CoveringLetter']['size'];
$file_tmp = $_FILES['upload_CoveringLetter']['tmp_name'];
$file_type = $_FILES['upload_CoveringLetter']['type'];
$file_ext = strtolower(end(explode('.',$_FILES['upload_CoveringLetter']['name'])));
$extensions = array("odt","doc","docx","pdf","jpeg", "jpg");
if(in_array($file_ext, $extensions) === false)
{
$uploadState = 0;
header('Location: ../addCandidacy.php');
}
else
{
if(!file_exists("Candidatures/".$Candidacy['candidacyType']) && !is_dir("Candidatures/".$Candidacy['candidacyType']))
{
mkdir("Candidatures/".$Candidacy['candidacyType']);
}
move_uploaded_file($file_tmp, "Candidatures/".$Candidacy['candidacyType']."/".$file_name);
$Candidacy['upload_CoveringLetter'] = $_SERVER['DOCUMENT_ROOT'];
}
}
答案 0 :(得分:0)
您的代码有误
mkdir("Candidatures/".$Candidacy['candidacyType']);
应该是
mkdir('Candidatures/'.$Candidacy['candidacyType'],0777, true);