Tuesday, February 15, 2022

[FIXED] Using HOST_WWW_ROOT on the MAMP stack

Issue

I'm currently trying to teach myself PHP and MySQL using the MAMP stack. Everything has been going good up until I came across this problem.

I am reading a book and completing the exercises as I go and I'm at the point where I have to let the user upload an image and then store that image on the web server. The book states that to do that, you make use of HOST_WWW_ROOT to set the location for the web files that will be uploaded.

I have done exactly how the book says to, however it is not working.

Is it possible to use this HOST_WWW_ROOT on localhost or can it only be used on a live server?


Solution

Every book will use something like SITE_ROOT or HOST_WWW_ROOT to refer to the location where your web server's public directory is located at.

MAMP FAQ:

Where should I store my HTML and PHP pages?

By default, PHP and HTML Pages should be stored inside the MAMP "htdocs" folder which is located in the MAMP Application directory /Applications/MAMP. This folder is called "Document Root". You can change the path for the Document Root in the MAMP application's Preferences Panel:

enter image description here

Now, depending on the platform you are developing your application on, some books would use something like SITE_ROOT, WWW_PUB, WWW_ROOT, etc. but they all refer, as you said, to the location where your 'web files' are.

See if there are some side notes indicating the book conventions.



Answered By - Saul Martínez

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.