我为我正在开发的一个网站创建了一个小型CMS,其中有一个表单可以上传图片文件以在网站上使用。它成功地上传文件,但它设置的权限不允许在浏览器中查看该文件。
以下是我当前用于上传文件的PHP代码:
$typepath = $_POST['filetype'];
$target_path = "../../images/uploads/".$typepath."/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "<p>The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded</p>\n<p>To the directory: <span style=\"font-weight:bold;\">".substr($target_path, 6)."</span></p>";
} else{
echo "There was an error uploading the file, please try again!";
}