douwen5246 2014-07-24 06:52
浏览 55
已采纳

无法在Ubuntu上使用PHP上传文件

I try a simple php upload file on Ubuntu, it not work. Even it work on Window

Here my html coded.

<form action="upload.php" method ="post" enctype="multipart/form-data">
    <input type="file" name="file" />
    <input type="submit" value="submit" name="submit"/>
</form>

Here my php coded.

<?php
  $name = $_FILES['file']['name'];
  $temp = $_FILES['file']['tmp_name'];

  if(move_uploaded_file($temp,"upload/".$name)){
   echo "Your file was uploaded";
}
 else
{ 
 echo "Your file cound't upload";
}

?>
  • 写回答

3条回答 默认 最新

  • dpw43061 2014-07-24 07:23
    关注

    Check that you have given the write access to the "APACHE" on the directory.

    Hope this will solve the problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • dshqd84261 2014-07-24 07:29
    关注

    This can be done by giving the write permission to the directory in ubuntu..

    You can see here on how to give write permissions..

    https://superuser.com/questions/19318/how-can-i-give-write-access-of-a-folder-to-all-users-in-linux

    评论
  • dongzhi1904 2019-06-07 08:40
    关注

    Change permission to UPLOAD file into upload folder on UBUNTU

    Read + Write

    sudo chmod -R a+rw upload/
    

    Read + Write + Execute

    sudo chmod -R a+rwx upload/
    
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 AES魔改之后的安全性关于PRF(相关搜索:密码学)
  • ¥15 用C语言写的一个程序遇到了两个问题第一是偏移正确但读取不到坐标,第二个问题是自己定义的函数实现不了获取指定进程模块。
  • ¥15 在安装Anaconda时总是闪退怎么办?
  • ¥15 对图中电路进行以下几个方面的分析
  • ¥15 对图中电路进行以下几个方面的分析
  • ¥15 对图中电路进行以下几个方面的分析
  • ¥15 对图中电路进行以下几个方面的分析
  • ¥500 抖音主页视频预存加载卡bug
  • ¥15 用汇编语言编写51单片机,定时闹钟程序
  • ¥20 关于TRPD(波形特征)局部放电特征提取