dongmie3526
2018-12-06 03:47 阅读 23
已采纳

网络邻居无法看到共享的move_uploaded_file

After an image is uploaded with PHP, I want to make the image can copy by neighbors in explorer.exe so server shared it's D:\xampp\htdocs and here is the code.

@move_uploaded_file($_FILES[$upload_file_name]['tmp_name'], $dir_base.$newFileName);

if (file_exists(realpath($dir_base . $newFileName))) {
  error_log("
 realpath 
".print_r(  realpath($dir_base.$newFileName) ,true)."
".date('Y-m-d H:i:s')."
",3,"html_cache/saveData.html");
  //will echo D:\xampp\htdocs\projectname\data1\bg\1812061109410.png

  chmod( realpath($dir_base . $newFileName),0644);
}

chmod is not working. Security has only Administrator without Everyone and System.

If I right click on xampp/tmp and add Everyone's security to it. It works fine but how can I make this by pure php?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dtja73027 dtja73027 2018-12-06 08:44

    As @Sakura Kinomoto said, chmod doesn't work on Windows environment. Use cacls.

    exec('echo Y|cacls '.realpath($dir_base . $newFileName).' /E /G Everyone:R');
    
    点赞 评论 复制链接分享

相关推荐