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
Post a Comment