Problem php routes - PATH

1

Good afternoon to everyone!

I tell you my problem: I have a file in which I can publish an announcement, but first I must make an include to the configuration file, where the connection variables and others are located. The fact is that by trying and testing I am not able to do the include. The files are uploaded to a school server, then I will leave the file structure and see how I can get the include. Thank you very much in advance!

   //comprobamos si la extension actual es una de las disponibles en el array $allowed
if (in_array($fileActualExt, $allowed)) {
    //comprobamos que no hay ningun error
    if ($fileError === 0) {
        //comprobamos el tamaño del archivo (kb)
        if ($fileSize < 10000000) {
            /*$rootPath = $_SERVER['DOCUMENT_ROOT'];
            echo "esta es la ruta " . $rootPath;
            echo $rootPath . '/config/dbh.inc.php';
            include_once($rootPath . '/config/dbh.inc.php');*/
            include_once('../config/dbh.inc.php');

            //nuevo nombre aleatorio para que nunca se repitan
            $fileNameNew = uniqid('', true).".".$fileActualExt;
            $fileDestination = $rootPath . 'uploads/'. $fileNameNew;

As you can see, the problem comes in the include_once('../config/dbh.inc.php); found in the file componentes/uploadAd/model.php

And here the structure of the project:

    
asked by Oscar Plumariega 12.12.2018 в 19:14
source

1 answer

1

Maybe this should be a comment, but I do not have enough reputation, I think you have to upload one more level in the file path, If your file is in /www/componentes/uploadAd/ and you upload only one level, you will be looking for a folder /www/componentes/config/ that according to the images does not exist, if you go up 2 levels if you find /www/config

include_once('../../config/dbh.inc.php');

    
answered by 12.12.2018 в 21:27