Open a direct file on the hard drive from firefox (file:///)

前端 未结 6 2143
难免孤独
难免孤独 2020-11-29 12:43

I have a small php system i created for myself. This system contains a few .doc and .docx file documents. I want to be able to open them directly from the browser and not do

6条回答
  •  感情败类
    2020-11-29 12:55

    My working code to open locally uploaded Files via Firefox (51.0) and the actual Internet Explorer (11).

    $pfad = trim(strip_tags(stripslashes(urldecode($_REQUEST['pfad']))));
    $datei = trim(strip_tags(stripslashes(urldecode($_REQUEST['file']))));
    exec ('start c:\\WINDOWS\\system32\\explorer.exe /select /seperate /n, /e, '.str_replace('/','\\',$pfad).utf8_decode($datei));
    

    saved as open.php

    "pfad" is a path BELOW the local Webroot (in my case customer folder) while "file" is - of course - the file which I want to open.

    I call it like so: ...href="open.php?pfad=&file="

    where both parameters are urlencoded

提交回复
热议问题