dsb12300 2016-01-18 09:39
浏览 55
已采纳

Php上传覆盆子pi上的脚本

I have set up a apache2 webserver on my raspberry pi (jessie). I have a file upload php script in my /var/www/html/ folder. This script is supposed to upload the file to a /uploads folder (/var/www/html/uploads). The script is:

$folder = "/uploads";
move_uploaded_file($_FILES["filep"]["tmp_name"] , "$folder".$_FILES["filep"]["name"]); 

When I try to upload a file, I get upload success message and the name of file gets updated to the database, but when I check the /uploads folder, I don't see the file. I have given chmod 777 permission to the folder and changed upload_max_filesize to 16M and post_max_size to 32M. None of the methods worked.

Is my path wrong or am I missing something?

  • 写回答

1条回答 默认 最新

  • douzhi2012 2016-01-18 09:55
    关注

    The folder /uploads is in your file system root and not under /var/www/html. To use a folder relative to the current directory leave out the leading / or use the constant __DIR__ to get the current directory.

    $folder = "uploads/"; 
    // or
    $folder = __DIR__."/uploads/"; 
    

    You could also use the complete path to the folder:

    $folder = "/var/www/html/uploads/";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真