PHP is_writeable或由其他程序打开? [英] PHP is_writeable or opened by another program?

查看:62
本文介绍了PHP is_writeable或由其他程序打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正常打开Microsoft Access文件,并且看到它被Micorsoft Office锁定了.然后,我尝试检查其是否可使用PHP编写:

I open a Microsoft Access file normally and I can see its locked by Micorsoft Office. I then attempt to check if its writeable with PHP:

echo '|--> '.is_writeable('C:\wamp\www\Database1.accdb');

但是它返回1.Surley,打开时应该返回0吗?

But it returns a 1. Surley, it should return a 0 when open?

只是测试,然后我尝试写给它:

Just to test, I then attempt to write to it:

$fh = fopen('C:\wamp\www\Database1.accdb', 'w+');

fwrite($fh, 'hello');

它让我这样做!无论如何,我可以确保文件是否没有被另一个程序打开吗?

It lets me do so! Is there anyway I can make sure if a file is not open by another program?

推荐答案

在打开Microsoft文档时,无论天气如何,它都会包含单词,PowerPoint或访问文件,应用程序都会在同一目录内创建一个文件,该文件被标记为隐藏,该文件告诉办公应用程序该文件正在被使用.

When you open a Microsoft document regardless weather its a word, power-point or access file the application will create a file within the same directory that is marked as hidden, this file is what tell's the office application that the file is being used.

相关文件为 NOT 被操作系统锁定,因此操作系统无法确定该文件是否由MS应用程序打开.

the file in question is NOT Locked by the operating system therefore the OS Cannot determine weather the file is opened by an MS Application.

您需要做的是检查锁定文件是否存在,然后这将使您能够确定相关应用程序当前打开文档的天气.

What you have to do is check to see if the lock file exists, this then will allow you to determine weather the document is currently open by the associated application.

类似的东西:

if(is_writeable("file.accdb") && !file_exists("file.lccdb"))
{
    touch("file.lccdb"); //mimic the file is being used

    /*
        * do Work
    */

    unlink("file.lccdb"); //Remove it
}

这篇关于PHP is_writeable或由其他程序打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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