Hello guys,
It seams to me that the PHP equivalent of the ASP Server.MapPath function has always been a nightmare for developers. PHP doesn't offer such function.
So, I'm here to open a discussion so we could maybe arrive in a definitive version of a PHP MapPath function (and maybe propose it to the PHP team).
Let us know about your experience with it and suggestions.
Important: it must take care of OS differences, aliases, virtual directories, etc...
We must produce the code of a "MapPath( $path )" function.
Thanks for your collaboration and welcome to this challenge.
Best regards,
FredCK
It seams to me that the PHP equivalent of the ASP Server.MapPath function has always been a nightmare for developers. PHP doesn't offer such function.
So, I'm here to open a discussion so we could maybe arrive in a definitive version of a PHP MapPath function (and maybe propose it to the PHP team).
Let us know about your experience with it and suggestions.
Important: it must take care of OS differences, aliases, virtual directories, etc...
We must produce the code of a "MapPath( $path )" function.
Thanks for your collaboration and welcome to this challenge.
Best regards,
FredCK
RE: PHP Gurus Called: Server.MapPath
Could you describe what the function should return? I'm not familiar with ASP at all, but have been coding PHP since the 20th century. It is possible I already have a function written up to do what you need.
Kae
RE: PHP Gurus Called: Server.MapPath
did you like to have something like realpath()?
http://php.net/manual/en/function.realpath.php
Ciao
GRon
RE: PHP Gurus Called: Server.MapPath
For example the following paths:
/UserFiles/Images/
../../Sample1.html
TestDir/File.xml
On IIS with a web site pointing to C:\MySite the MapPath must return:
C:\MySite\UserFiles\Images\
C:\MySite\SampleDir\Sample1.html (assuming we are 2 level directories under SampleDir)
C:\MySite\AnotherDir\TestDir\File.xml (assuming we are at "AnotherDir".
The same thing on Linux to a site that points to /roor/www/mysite:
/roor/www/mysite/UserFiles/Images/
/roor/www/mysite/SampleDir/Sample1.html (assuming we are 2 level directories under SampleDir)
/roor/www/mysite/AnotherDir/TestDir\File.xml (assuming we are at "AnotherDir".
It must also work in a sample case that "/UserFiles/", for example, points to C:\UploadDirs\UserFiles\ on IIS or /root/userfiles on Linux, producing the following outputs for the first sample:
C:\UploadDirs\UserFiles\Images\
/root/userfiles/Images/
For further information, try to search "asp server mappath" at Google.
Thanks again.
FredCK
Frederico Knabben
CKEditor Project Lead and CKSource Owner
--
Follow us on: Twitter | Facebook | Google+ | LinkedIn
RE: PHP Gurus Called: Server.MapPath
function MapPath($file){
$alu=apache_lookup_uri($file);
return $alu->filename;
}
there may be more generic methods. I'll look for them.
RE: PHP Gurus Called: Server.MapPath
RE: PHP Gurus Called: Server.MapPath
- It does not work with Virtual Directories or Aliases.
- It does not work if the path doesn't exist (for this one we could find other solutions).
- It seams that it doesn't accepts paths like "/UserFiles/".
Actually this is a job that can't be done by only parsing the path and try to rebuild it based on the root. There must be a web server integrations so the web server retrieves the information, considering Virtual Directories and Aliases. (actually this is the way the ASP MapPath works).
The apache_lookup_uri function seams to be a step to make it work, but it is only limited to Apache and PHP must be installed as an Apache Module.
Lets see you all you have a brilliant idea to solve all those issues. I think we'll have a lot of code here to do that.
FredCK
Frederico Knabben
CKEditor Project Lead and CKSource Owner
--
Follow us on: Twitter | Facebook | Google+ | LinkedIn