Hi,

Im working on a intranet website.

I have multiple folders on a windows 2008 server.
Each folder has it unique number and name like 123456_bla_bla

I would like to access each folder from my website but i only got the 123456 as reference in my database (mysql).

Is it possible to get php to open the folder 123456_bla_bla based on only the first numbers?

My website is running on the same server where the folders are so it would only be something like this:
echo ("<a href=\"file://server/$variable\">Link to folder</a>");

Best regards

Recommended Answers

All 2 Replies

I would like to access each folder from my website but i only got the 123456 as reference in my database (mysql).

you dont know or have no reference to the rest of the folder name? How are these folders created?

Is it possible to get php to open the folder 123456_bla_bla based on only the first numbers?

You would have to know what the "_bla_bla" value is so that when you create the hyperlink, the rest of "123456" is included in the path.

You would have this value somewhere stored, or you would need to read from the file system to get the folder names, etc... Somehow you have to have this info so you can build the hyperlink.

Member Avatar for Zagga

A JorgeM said, you need to know the full path before you can build a hyperlink.

If the number part of the folder name is unique, you could use something like ...

$all_subfolders = glob("path/to/folders/*", GLOB_ONLYDIR);

... to give you an array containing all the folder names, then search through the array to find the folder that matches the numbers you have stored in the database.

This will not work if you have more than 1 folder with the same numbers (eg 123456_bla_bla and 123456_foo_bar). If this is the case you would be better off saving the full path in the database instead of just the number part.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.