Mary
Mary

Reputation: 1

How to find the web root of a hosting in PHP

How to find the web root (www, html_public, etc) of a hosting to upload files automatically via the PHP ftp_put() function ?

The purpose is to propose the installation of a PHP script via a form or the users could send their FTP login.

Then, with a function PHP would upload and install the script remotely on the server. My complete function works perfectly, however I was unable to determine the web directory of the server.

Thank you in advance for your help.

Kind regards

Upvotes: 0

Views: 7040

Answers (2)

Rikesh
Rikesh

Reputation: 26421

Have you check $_SERVER ?

Try this,

echo $_SERVER["DOCUMENT_ROOT"];

Upvotes: 3

OptimusCrime
OptimusCrime

Reputation: 14863

Not 100% sure what you are trying to do here, but by uploading a file in your webroot with this content:

echo dirname(__FILE__);

You could receive the full root path on your server.

Upvotes: 1

Related Questions