{"id":2232,"date":"2016-06-14T17:41:13","date_gmt":"2016-06-14T15:41:13","guid":{"rendered":"http:\/\/www.hyperpac.de\/?p=2232"},"modified":"2016-06-14T18:05:30","modified_gmt":"2016-06-14T16:05:30","slug":"howto-get-the-relative-path-of-a-file-folder-in-unix-linux-with-php","status":"publish","type":"post","link":"https:\/\/www.hyperpac.de\/?p=2232","title":{"rendered":"Howto get the relative path of a file \/ folder in Unix \/ Linux with PHP"},"content":{"rendered":"<p>Sometimes you\u00b4ll need the relative path of a file or folder stored on your webserver. Especially if you\u00b4re one a shared environment this can be a bit tricky sometimes.<\/p>\n<p>Here is a short and easy solution for your problem:<\/p>\n<ul>\n<li>create a php file named &#8216;fullpath.php&#8217;<\/li>\n<li>open the file and enter the following php code<\/li>\n<li>\n<div id=\"post-9\" class=\"post\">\n<div class=\"entry\">\n<pre>&lt;?php\r\n$dir = dirname(__FILE__);\r\necho \"&lt;p&gt;Full path to this dir: \" . $dir . \"&lt;\/p&gt;\";\r\necho \"&lt;p&gt;Full path to a .htpasswd file in this dir: \" . $dir . \"\/.htpasswd\" . \"&lt;\/p&gt;\";\r\n?&gt;<\/pre>\n<\/div>\n<\/div>\n<\/li>\n<li>upload the file to the folder on your webserver which you want to know the path\u00a0(f.e. www.yourwebserver.com\/yourfolder\/)<\/li>\n<li>open your webbrowser and go to the location you\u00b4ve uploaded the file (f.e. www.yourwebserver.com\/yourfolder\/fullpath.php)<\/li>\n<li>enjoy your relative path (which could look f.e. something like this\u00a0\u00a0&#8216;\/var\/www\/vhosts\/yourwebserver.com\/httpdocs\/yourfolder&#8217;)<\/li>\n<li>Note: if you plan to use this relative path for other applications you may need to add an additional &#8216;\/&#8217; at the end (&#8216;\/var\/www\/vhosts\/yourwebserver.com\/httpdocs\/yourfolder\/&#8217;)<\/li>\n<\/ul>\n<p><em>Source:\u00a0http:\/\/www.htaccesstools.com\/articles\/full-path-to-file-using-php\/<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you\u00b4ll need the relative path of a file or folder stored on your webserver. Especially if you\u00b4re one a shared environment this can be a bit tricky sometimes. Here is a short and easy solution for your problem: create a php file named &#8216;fullpath.php&#8217; open the file and enter the following php code &lt;?php &hellip; <a href=\"https:\/\/www.hyperpac.de\/?p=2232\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Howto get the relative path of a file \/ folder in Unix \/ Linux with PHP<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[1182,262,176,198,1180,1181],"class_list":["post-2232","post","type-post","status-publish","format-standard","hentry","category-it_wordpres","tag-file","tag-folder","tag-linux","tag-php","tag-relative-path","tag-unix"],"_links":{"self":[{"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/posts\/2232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2232"}],"version-history":[{"count":3,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/posts\/2232\/revisions"}],"predecessor-version":[{"id":2235,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/posts\/2232\/revisions\/2235"}],"wp:attachment":[{"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}