Home  >  Article  >  Backend Development  >  PHP下传图片出错:没有权限

PHP下传图片出错:没有权限

WBOY
WBOYOriginal
2016-06-13 11:14:58910browse

PHP上传图片出错:没有权限

本帖最后由 wxg694175346 于 2013-02-03 00:32:23 编辑 PHP上传文件的小案例:
<?php<br />if ((($_FILES["file"]["type"] == "image/gif")<br />|| ($_FILES["file"]["type"] == "image/jpeg")<br />|| ($_FILES["file"]["type"] == "image/pjpeg"))<br />&& ($_FILES["file"]["size"] < 20000))<br />  {<br />  if ($_FILES["file"]["error"] > 0)<br />    {<br />    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";<br />    }<br />  else<br />    {<br />    echo "Upload: " . $_FILES["file"]["name"] . "<br />";<br />    echo "Type: " . $_FILES["file"]["type"] . "<br />";<br />    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";<br />    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";<br /><br />    if (file_exists("upload/" . $_FILES["file"]["name"]))<br />      {<br />      echo $_FILES["file"]["name"] . " already exists. ";<br />      }<br />    else<br />      {<br />      move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]);<br />      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];<br />      }<br />    }<br />  }<br />else<br />  {<br />  echo "Invalid file";<br />  }<br />?>


反应是:

Warning: move_uploaded_file(upload/12.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied inupload_file.php on line24

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/saetmp/928/xququer/1359821561_2429732845/phppSXyZ6' to 'upload/12.jpg' inupload_file.php on line24


google了一下应该是没有权限。。。linux下可以用chmod 777 filename的方法,但是windows下面怎么办?右击将upload文件夹的只读的选项去掉之后,关闭窗口再看属性还是只读。

怎么办。。(我是用的SAE,新浪云服务器,不是本地搭建的Apache)

------解决方案--------------------
windows下右键->属性->安全->编辑->添加everyone->底下需要的权限打钩
------解决方案--------------------
你设置了 upload_tmp_dir 吗?
如果没有设置的话,将会使用操作系统的临时目录,而对于 XP 以上(不含XP)的操作系统这个目录是不对匿名用户开放的
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn