【问题标题】:How do i create a file on a network client from a network web server如何从网络 Web 服务器在网络客户端上创建文件
【发布时间】:2016-01-23 00:08:37
【问题描述】:

我在业务网络上设置了一个网络服务器。我正在使用 php 创建一个文件,我想将它写入网络上的本地客户端共享文件夹。当我从客户端 ping 时,我得到了网络服务器的响应。当我从网络服务器 ping 时,我得到了客户端的响应。这是我的代码。我收到权限错误。有什么想法可能导致这种情况吗?路径是否正确?如何制定路径?

    $fileName = "\\\\7PD01-2012.payday.local\\PTBurnJobs\\file.txt";
    var_dump($fileName);
    if (($myfile = fopen($fileName, "w+")) === false) { //open the file
           //if unable to open throw exception
           throw new RuntimeException("Could Not Open File Location.");
    }
    foreach($arr as $line){
           fwrite($myfile, $line . PHP_EOL);

    }
    fclose($myfile);

在网络服务器上创建文件然后将其传输到客户端会更谨慎吗?我该怎么做?

【问题讨论】:

  • 你在这方面有进展吗?

标签: php windows file ubuntu client


【解决方案1】:

如果您遇到权限错误,那么您需要检查运行您的 php 脚本/网络服务器的用户是否在客户端文件夹中具有写入权限。

问你一个问题: 你怎么知道你得到一个权限错误?上面的代码没有检查为什么失败了,只是检查失败了。

如果您收到权限错误,则听起来好像建立了成功的连接,并且您至少尝试成功传输文件,只是被您的 ACL 层阻止。

【讨论】:

  • 警告:fopen(\\7PD01-2012.payday.local\PTBurnJobs\file.txt):无法打开流:/var/www/html/CDprinter/processor.php 中的权限被拒绝第 139 行
  • fopen上线139行
  • 是的,您的网络服务器用户被阻止写入网络位置,需要修复。
猜你喜欢
  • 2011-03-30
  • 1970-01-01
  • 2012-04-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-30
  • 2011-12-26
相关资源
最近更新 更多