如何通过SMB挂载复制PHP [英] How to PHP copy across SMB mount

查看:314
本文介绍了如何通过SMB挂载复制PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的脚本,将文件从一个SMB挂接复制到另一个。源文件系统是相同的,但Web服务器是不同的。我使用PHP处理文件通过将其复制到临时目录,然后执行额外的任务。这个设置在一个时间点工作,但似乎它不再正常工作。有人可以指向正确的方向吗?



fstab mounts

  // 192.168.0.x / share / media / folder smbfs username = user,password = mypass 
//192.168.0.x/share2 / media / folder2 smbfs username = user ,password = mypass

PHP代码

  copy('/ media / folder / filename.txt','/ media / folder2 / temp / filename.txt'); 

错误

 警告:复制(/media/folder2/temp/filename.txt):无法打开流:在线xx 
上拒绝/www/myphp.php中的权限



文件夹权限(不是装载,而是文件服务器上的源文件夹):

  / media / folder = 777 
/ media / folder2 / temp = 777


解决方案

我将命令更改为:

  copy('/ media / folder / filename.txt','/ tmp / filename.txt'); 

显然,在SMB共享上处理文件比我想象的更困难。该文件应该在计算机重新启动时删除,或者可能是定期的,取决于系统设置。


I have a simple script which copies a file from one SMB mount to another. The source file system is the same, but the web server is different. I'm using PHP to process the file by copying it to a temp directory, then performing additional tasks on it. This setup was working at one point in time but it seems that it's no longer working correctly. Can someone point me in the right direction?

fstab mounts:

//192.168.0.x/share /media/folder smbfs username=user,password=mypass
//192.168.0.x/share2 /media/folder2 smbfs username=user,password=mypass

php code:

copy('/media/folder/filename.txt','/media/folder2/temp/filename.txt');

Error:

Warning: copy(/media/folder2/temp/filename.txt): failed to open stream: Permission denied in /www/myphp.php on line xx

Folder permissions (not the mount, but the source folder on the fileserver):

/media/folder = 777 
/media/folder2/temp = 777

解决方案

I changed the command to:

copy('/media/folder/filename.txt','/tmp/filename.txt');

Apparently it's more difficult to process files on an SMB share than I thought. The file should be removed when the computer's rebooted, or possibly at regular intervals, depending on the system setup.

这篇关于如何通过SMB挂载复制PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆