开发者

How can I convert directory path to full URL

开发者 https://www.devze.com 2023-02-20 20:13 出处:网络
I want to convert directory paths to absolute URLs. For eg. C:\\example\\myfile to http://e开发者_开发问答xample.com/myfile

I want to convert directory paths to absolute URLs. For eg.

    C:\example\myfile to http://e开发者_开发问答xample.com/myfile

How can I do this? Please help me.


Use the $_SERVER['SERVER_NAME'] property to get the domain you are running on, then append it to the root of your file location.

i.e. If file is in C:\www\mydir\myfile.file, then

$url = $_SERVER['SERVER_NAME'].'/mydir/myfile.file';


Use preg_replace.

0

精彩评论

暂无评论...
验证码 换一张
取 消