douhan5547
2015-05-03 03:27
浏览 196
已采纳

如何在JavaScript中从服务器链接获取文件的直接链接?

So, now I have a file. The file is at /home/johndoe/index.html.

I host, using something like XAMPP, which hosts the folder /home at localhost.

So this is the list of variables I have:

$server_addr = "localhost";
$server_root = "/home";
$file_dir = "/home/johndoe/index.html";

Now, in PHP, I'm trying to get the link to access /home/johndoe/index.html.

What I want to do:

function getLink($file_dir, $server_addr, $server_root) {
    // Do something here
    return "SOMETHING HERE";
}

echo getLink("/home/johndoe/index.html", "localhost", "/home");
// Expect 'localhost/johndoe/index.html' here.

I decided that only doing things on the thing is not a wise way.

Is there any native functions, or how can I write a function by 'using' the file instead of doing something on these three string's?

图片转代码服务由CSDN问答提供 功能建议

所以,现在我有了一个文件。 该文件位于 /home/johndoe/index.html

我主持,使用XAMPP之类的东西,它承载文件夹 / home at localhost

所以这是我拥有的变量列表:

  $ server_addr =  “localhost”; 
 $ server_root =“/ home”; 
 $ file_dir =“/ home / johndoe / index.html”; 
  
nn

现在,在 PHP,我正在尝试获取访问 /home/johndoe/index.html 的链接。

我想做什么: \ n

  function getLink($ file_dir,$ server_addr,$ server_root){
 //在这里做点什么
返回“SOMETHING HERE”; 
} 
 
echo getLink(“/ home /  johndoe / index.html“,”localhost“,”/ home“); 
 //在这里预期'localhost / johndoe / index.html'。
   
 
 

我决定只对事物做事情不是明智的方法。

是否有任何原生函数,或者如何通过“使用”文件而不是做某事来编写函数 这三个字符串?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题