ffmus123 Posted August 12, 2011 Share Posted August 12, 2011 Hello fellow php users. I am trying to read the contents of a Local Shared Object file (.sol) stored in Application Data. The problem is that one of the directories is named with a random string which is different for each user. For example I am trying to read the file info.sol stored in %APPDATA%\Macromedia\Flash Player\#SharedObjects\[random string]\mywebsite.com\info.sol . The environment variable %APPDATA% points to C:\Users\Username\AppData\Roaming\ on my machine, however I am not sure if php can use windows environment variables? I have tried using readdir() and scandir() functions with the %APPDATA% path to try and find the name of the 'random string' directory however php doesn't seem to recognise the path $dir = "%APPDATA%/Macromedia/Flash Player/#SharedObjects/"; $dh = opendir($dir); $first = readdir($dh); echo $first; If php can't use the %APPDATA% path then I will have to use the same method to bypass the random username directory as I do for the 'random string' directory, I just don't know how I can get this working. This is all so I can make a php score display page to read info.sol which is created by a flash game on my site. Many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/244608-get-path-to-a-file-when-directory-name-in-unknown/ Share on other sites More sharing options...
ffmus123 Posted August 12, 2011 Author Share Posted August 12, 2011 Still can't get it to work, even with scandir(). Quote Link to comment https://forums.phpfreaks.com/topic/244608-get-path-to-a-file-when-directory-name-in-unknown/#findComment-1256478 Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 12, 2011 Share Posted August 12, 2011 php file exists Quote Link to comment https://forums.phpfreaks.com/topic/244608-get-path-to-a-file-when-directory-name-in-unknown/#findComment-1256482 Share on other sites More sharing options...
ffmus123 Posted August 12, 2011 Author Share Posted August 12, 2011 file_exists() won't allow incomplete paths. Plus only would work if I try and get the random directory name, any other suggestions? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/244608-get-path-to-a-file-when-directory-name-in-unknown/#findComment-1256493 Share on other sites More sharing options...
ffmus123 Posted August 12, 2011 Author Share Posted August 12, 2011 ok I have figured out how to get the random string directory name using scandir(), however I can't use %APPDATA% in the path name, is there a workaround? Quote Link to comment https://forums.phpfreaks.com/topic/244608-get-path-to-a-file-when-directory-name-in-unknown/#findComment-1256502 Share on other sites More sharing options...
requinix Posted August 12, 2011 Share Posted August 12, 2011 Use getenv and glob. print_r(glob(getenv("APPDATA") . "\\Macromedia\\Flash Player\\#Shared Objects\\*\\mywebsite.com\\info.sol")); Quote Link to comment https://forums.phpfreaks.com/topic/244608-get-path-to-a-file-when-directory-name-in-unknown/#findComment-1256504 Share on other sites More sharing options...
ffmus123 Posted August 12, 2011 Author Share Posted August 12, 2011 Use getenv and glob. print_r(glob(getenv("APPDATA") . "\\Macromedia\\Flash Player\\#Shared Objects\\*\\mywebsite.com\\info.sol")); Thank you, i'm suprised I didn't find the getenv() function through searching. However the path it returns is not the same as the path when doing cd %APPDATA% in command prompt. It seems to go to the system appdata profile. Anyway to get the users appdata? Quote Link to comment https://forums.phpfreaks.com/topic/244608-get-path-to-a-file-when-directory-name-in-unknown/#findComment-1256511 Share on other sites More sharing options...
requinix Posted August 12, 2011 Share Posted August 12, 2011 Thank you, i'm suprised I didn't find the getenv() function through searching. However the path it returns is not the same as the path when doing cd %APPDATA% in command prompt. It seems to go to the system appdata profile. Anyway to get the users appdata? You probably have PHP running as a system user (NETWORK SERVICE I think), and probably because it's in IIS or Apache which is running as a service. It doesn't know about other users, least of all not who "you" are. Just hardcode the path. Quote Link to comment https://forums.phpfreaks.com/topic/244608-get-path-to-a-file-when-directory-name-in-unknown/#findComment-1256532 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.