更改由PHP上传的文件的权限
发布时间:2020-12-13 17:36:54 所属栏目:PHP教程 来源:网络整理
导读:我为我正在开发的网站创建了一个小规模的CMS,并且具有上传要在网站上使用的图像文件的表单.它可以成功上传文件,但它设置的权限不允许在浏览器中查看文件. 这是我目前的PHP代码上传文件 $typepath = $_POST['filetype'];$target_path = "../../images/uploads
我为我正在开发的网站创建了一个小规模的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!"; }
PHP Manaual chmod
http://php.net/manual/en/function.chmod.php
chmod("/somedir/somefile",0755); 在上下文中; $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)) { chmod($target_path,0755); 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,please try again!"; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |