我的网站托管在000webhost中,我已经在文件管理器中创建了一个名为“Uploaded CVs”的目录,但是我收到了这个错误:
警告:move_uploaded_file()[function.move-uploaded-file]:open_basedir限制生效
php代码:
<?php
$file_result = "";
if ($_FILES["file"]["error"] >0)
{
$file_result .="File did not upload! Try again!";
$file_result .="Error occured: " . $_FILES["file"]["error"] . "<br>";
}else{
$file_result.=
"Upload: " . $_FILES["file"]["name"] . "<br>" .
"Type: " . $_FILES["file"]["type"] . "<br>" .
"Size: " . ($_FILES["file"]["size"] / 1024 ). " Kb<br>" .
"Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
move_uploaded_file($_FILES["file"]["tmp_name"],
$_SERVER['DOCUMENT_ROOT'] . "/Uploaded CVs/" . $_FILES["file"]["name"]);
$file_result .= "CV Uploaded Successfully!";
}
?>
任何想法都是正确的道路吗?感谢。
答案 0 :(得分:0)
对于此示例,文件夹与文件位于同一路径中。
<?php
$file_result = "";
if ($_FILES["file"]["error"] >0)
{
$file_result .="File did not upload! Try again!";
$file_result .="Error occured: " . $_FILES["file"]["error"] . "<br>";
}else{
$file_result.=
"Upload: " . $_FILES["file"]["name"] . "<br>" .
"Type: " . $_FILES["file"]["type"] . "<br>" .
"Size: " . ($_FILES["file"]["size"] / 1024 ). " Kb<br>" .
"Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
if (move_uploaded_file($_FILES["file"]["tmp_name"], "Uploaded CVs/".$_FILES["file"]["name"])) {
$file_result .= "CV Uploaded Successfully!";
} else {
$file_result .= "Error trying to uploas the file";
}
}
?>