php - convert a string of full path to relative base url path -


my problem when uploading file, retrieve full path

c:/xampp/htdocs/public_html/gtc/wc-upload/gallery/ 

and (c:/xampp/htdocs/public_html/gtc/) root directory. required full path string should relative base url http://gtc.app/wc-upload/gallery/. how reform string that?

you can use this:

<?php  $stringtofind = 'c:/xampp/htdocs/public_html/gtc/';  $path = 'c:/xampp/htdocs/public_html/gtc/wc-upload/gallery/';  $url = 'http://gtc.app/';    $pos = strpos($path, $stringtofind); if ($pos === 0) {     $url .= substr($path,strlen($stringtofind));     }  echo $url."<br />"; 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -