PHP: el sistema no puede encontrar la ruta especificada. (pero lo encuentra en otro archivo)

My main app is at:


What I do from there is parse a directory

foreach (new DirectoryIterator('./app/uploads/images/') as $fileInfo) {
    if($fileInfo->isDot()) continue;
    $images[] = $fileInfo->getFilename();

And it works ok.

But, when I do the exact same thing from


I get the error from the title.

¿Alguna pista de lo que estoy haciendo mal?

I also tried modifying path to '../app/uploads/images/' but have no clue what else to do.


preguntado el 09 de marzo de 12 a las 16:03

Cambiándolo a ../app/uploads/images hace el directorio ./app/app/uploads/images -

2 Respuestas

The difference and simple problem is:

You're two scripts are not in the same directory. If you use the './directory' notation, the '.' means starting at your current directory which is one time 'app' and the other time 'app/models/'.

Solve the problem by changing the path string in 'app/models/tricky.php' to '../uploads/images/'. The double dot '..' is important, it stands for the parent directory (go one directory up).

respondido 09 mar '12, 16:03

Thanks for solving my problem, and also +1 for clear explanation, it is really helpful. - CódigoVirtuoso

Depending on how you have your routing set up, does:


produce a result?

Also, you might implement:


and see what you get (it'll produce a boolean value.

Let me know the results and perhaps that'll lead us somewhere helpful.

respondido 09 mar '12, 16:03

Thanks a lot for the help. is_dir returned false, and modifying the path as above also didn't give results. What could be the next step? - CódigoVirtuoso

Another answer solved it for me, but thanks for help and also for teaching me new function I didn't know about. - CódigoVirtuoso

@Freelancer - yes. I use it quite a lot. It's a nice way to be able to test a handful of paths at once, without having to constantly reload, etc. Glad you solved it. Bests, - AshBrad

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.