2010-05-05 3 views
2

For an Intranet web application (document management), I want to show a list of files associated with a certain customer. The resulting HTML is like this:<a href="local file"> is opened outside of browser

<a href="file:///server/share/dir/somefile.docx">somefile.docx</a> 
<a href="file:///server/share/dir/someotherfile.pdf">somefile.pdf</a> 
<a href="file:///server/share/dir/yetanotherfile.txt">yetanotherfile.txt</a> 

This works fine. Unfortunetly, when clicking on a text file (or image file), Internet Explorer (and I guess most other browsers as well) insist on showing it in the browser instead of opening the file with the associated application (e.g. Notepad). In our case, this is undesired behavior, since it does not allow the user to edit the file.

Is there some workaround to this behavior (e.g. something like <a href="file:///..." open="external">)? I'm aware that this is a browser-specific thing, and an IE-only solution would be fine (it's an Intranet application after all).

+0

추신 : 서버에서 파일을 열고'Content-disposition : attachment'를 사용하여 스트리밍하는 것은 옵션이 아닙니다. 사용자가 파일의 로컬 사본 *을 편집 할 수 있도록 허용하기 때문입니다. – Heinzi

+0

사용자가 해당 응용 프로그램에서 파일을 직접 열어도 파일은 여전히 ​​로컬 복사본입니다. – dnagirl

+0

@dnagirl : 아니에요. 적어도 IE는 파일의 로컬 사본을 다운로드하지 않고 응용 프로그램에 UNC 경로를 전송할만큼 똑똑합니다. – Heinzi

답변

1

Do you WANT people to just mess around with things lying on your server? That reeks of lack of security to me...

I'd recommend letting the user check it out locally and using a database or similar to allow people to check in new drafts. Said drafts should be verified and validated somehow before they are actually written to the server's filesystem.

+2

예, 필수 사항입니다. 공통 파일이 네트워크 공유에 위치하고 모든 파일이 "내부에서"편집되는 소규모 기업을위한 소프트웨어입니다. 파일 액세스는 NTFS 사용 권한으로 관리됩니다. – Heinzi

0

I just tested this and it seems to work (IE6, not in FF or Chrome):

<HTML> 
<script language="JavaScript"> 
    function startWord(strFile) 
    { 
    var myApp = new ActiveXObject("Word.Application"); 
    if (myApp != null) 
    { 
     myApp.Visible = true; 
     myApp.Documents.Open(strFile); 
    } 
    } 
</script> 
<a href="javascript:startWord('file:///server/share/dir/test.doc')">test.doc</a>. 

Found it here을 확인하십시오.

+0

고마워요,하지만 Word 파일은 여기서 문제가되지 않습니다. 문제는 텍스트 파일, 이미지 파일 및 IE가 인라인으로 표시 할 수있는 다른 유형의 파일입니다. – Heinzi

+0

내가 참조한 링크가 표시됩니다. 다른 파일 유형/프로그램 연관이 있습니다. 나는 적어도 당신이 올바른 방향으로 향하게 할 수 있습니다. 또 다른 대안은 사용자 정의 프로토콜을 작성하는 것이지만 로컬 시스템에 설치 또는 regedit가 필요합니다. –