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

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

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