webDAV / PHP - 从HTML Anchor打开MS Word文档?

时间:2022-09-16 09:48:09

Can someone explain this strange (or normal) behaviour: I've got a WebDAV directory. In this folder, I have a word document, called document.doc.

有人可以解释这种奇怪的(或正常的)行为:我有一个WebDAV目录。在这个文件夹中,我有一个名为document.doc的word文档。

When I open Word, and then choose "Open File" and fill in the whole URL, http://server/webdav/document.doc, Word will open the document just fine. Changes I make are being saved on save click.

当我打开Word,然后选择“打开文件”并填写整个URL,http://server/webdav/document.doc时,Word将打开文档就好了。我所做的更改将在保存点击时保存。

Now, when I make a HTML page with an anchor to this document like this:

现在,当我创建一个带有锚点的HTML页面时,这样:

<a href="http://server/webdav/document.doc">Edit document</a>

It will open the document just fine, but opens in Read-Only mode!

它会打开文档就好了,但是以只读模式打开!

Investigation suggests that when you use Word to open the file, it will also function as WebDav client. So it will send the appropriate headers to lock the file etc. Calling it from an anchor, lets your browser do the GET. Then it will pass the document (downloaded??) to Word. Word does some HTTP calls on the file, but no LOCK and so.

调查表明,当您使用Word打开文件时,它也将用作WebDav客户端。因此它会发送相应的标题以锁定文件等。从锚点调用它,让您的浏览器执行GET。然后它会将文件(下载??)传递给Word。 Word对文件执行一些HTTP调用,但没有LOCK等。

Does anyone have any idea how I can solve this? I could write some PHP code to do the HTTP calls and so, but how do I get it in Word then?

有谁知道如何解决这个问题?我可以编写一些PHP代码来执行HTTP调用,但是,我如何在Word中获取它?

3 个解决方案

#1


I wouldn't expect this to be possible. When you open it through your web-browser, you're first downloading a copy that's then stored in a temp folder and then handed to word. What you're looking for is having word open the document. Hence, what you would need to do is have the link open up word and pass it a parameter. A very nasty hack would be to have php generate files readable by word that make it open the desired webdav-document. You could do this with macros, but a) you'd need to lower your macro security settings in word and b) you'd never be able to rely on others having done this (hence, it's just a solution for you).

我不希望这是可能的。当您通过Web浏览器打开它时,您首先要下载一个副本,然后将其存储在临时文件夹中,然后传递给单词。你正在寻找的是打开文件。因此,您需要做的是让链接打开单词并传递一个参数。一个非常讨厌的黑客将是让php生成可以通过单词读取的文件,使其打开所需的webdav文档。您可以使用宏来执行此操作,但是a)您需要降低单词中的宏安全设置,并且b)您永远无法依赖其他人完成此操作(因此,它只是一个解决方案)。

#2


See this question. Basically you use a bit of Javascript that calls an ActiveX object that is part of Microsoft Sharepoint.

看到这个问题。基本上你使用一些Javascript来调用属于Microsoft Sharepoint的ActiveX对象。

#3


IIRC, Confluence (Atlassian) has a WebDav add-in for Firefox that accomplishes this (opening a doc in Word in WebDav mode by clicking on a link in the browser). Not sure how it's done, however.

IIRC,Confluence(Atlassian)有一个用于Firefox的WebDav插件,可以完成此操作(通过单击浏览器中的链接在WebDav模式下打开Word中的文档)。但是,不确定它是如何完成的。

#1


I wouldn't expect this to be possible. When you open it through your web-browser, you're first downloading a copy that's then stored in a temp folder and then handed to word. What you're looking for is having word open the document. Hence, what you would need to do is have the link open up word and pass it a parameter. A very nasty hack would be to have php generate files readable by word that make it open the desired webdav-document. You could do this with macros, but a) you'd need to lower your macro security settings in word and b) you'd never be able to rely on others having done this (hence, it's just a solution for you).

我不希望这是可能的。当您通过Web浏览器打开它时,您首先要下载一个副本,然后将其存储在临时文件夹中,然后传递给单词。你正在寻找的是打开文件。因此,您需要做的是让链接打开单词并传递一个参数。一个非常讨厌的黑客将是让php生成可以通过单词读取的文件,使其打开所需的webdav文档。您可以使用宏来执行此操作,但是a)您需要降低单词中的宏安全设置,并且b)您永远无法依赖其他人完成此操作(因此,它只是一个解决方案)。

#2


See this question. Basically you use a bit of Javascript that calls an ActiveX object that is part of Microsoft Sharepoint.

看到这个问题。基本上你使用一些Javascript来调用属于Microsoft Sharepoint的ActiveX对象。

#3


IIRC, Confluence (Atlassian) has a WebDav add-in for Firefox that accomplishes this (opening a doc in Word in WebDav mode by clicking on a link in the browser). Not sure how it's done, however.

IIRC,Confluence(Atlassian)有一个用于Firefox的WebDav插件,可以完成此操作(通过单击浏览器中的链接在WebDav模式下打开Word中的文档)。但是,不确定它是如何完成的。