Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP Scandir error

Wes.

Active Coder
I am trying to use scandir to find files and folders in a directory. The directory containing the code is 'mobile' while the directory containing the sub directories to be scanned is called 'downloads', they are both inside another directory called 'BOLDzBRASS' which is in the root directory.
So we have 'BOLDzBRASS/mobile' (containing my webpage file) and 'BOLDzBRASS/downloads'.
If I use "scandir('downloads')" from within the 'mobile' directory it fails with the error "failed to open dir: No such file or directory ", BUT if I move my file out of 'mobile' and into the 'BOLDzBRASS' directory it works perfectly!
I have tried various variations like "scandir('www.fmtest.info/BOLDzBRASS/downloads')" or "scandir('/public_html/BOLDzBRASS/downloads')" but with no success.
I would really like to have my file in the 'mobile' directory with all the mobile web pages just to keep things tidy. Can anyone throw any light on this?
 
From within the "mobile" directory, try this:

PHP:
scandir("../downloads");

The ../ means go up one directory.
Thanks for your reply. I have already tried that, along with a number of other suggestions I have found with a Google search. None of them work, thats what is so baffling about this, scandir just doesnt want to go back one directory for some reason. At the moment I have moved the file to the 'BOLDzBRASS' directory, from which it works perfectly well, but I would like to have it in 'mobile' for the sake of tidyness, but if it has to be it has to be. I just wondered if anyone on here had come up against the same thing, or had done the same thing successfully.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom