hanhao Posted May 29, 2006 Share Posted May 29, 2006 problem with specifying directory when using file_get_content()i got a problem with this functionsim.txt is the file that i wish to read. it is stored in website_root\color_scripts\sim.txtthis is my code [b]$simtxt_contents = file_get_contents("color_scripts\sim.txt");[/b]here is the error message[b]Warning: file_get_contents(color_scripts\sim.txt) [function.file-get-contents]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\website_root\test_colorsim.php on line 21[/b]the strange thing is i specified the directory as "color_scripts\sim.txt" , and NOT \test_colorsim.php\is there anyway to solve this problem?do i need to escape ta directory up?using apache on my computerplease help Link to comment https://forums.phpfreaks.com/topic/10690-problem-with-specifying-directory-when-using-file_get_content/ Share on other sites More sharing options...
trq Posted May 29, 2006 Share Posted May 29, 2006 You might try escaping your backslash. eg;[code]file_get_contents("color_scripts\\sim.txt");[/code] Link to comment https://forums.phpfreaks.com/topic/10690-problem-with-specifying-directory-when-using-file_get_content/#findComment-39889 Share on other sites More sharing options...
hanhao Posted May 29, 2006 Author Share Posted May 29, 2006 thnx for reply!i managed to solve my problemhere is the solution$server_root = $_SERVER['DOCUMENT_ROOT']; $simtxt_contents = file_get_contents("$server_root/website_root/color_scripts/sim.txt"); Link to comment https://forums.phpfreaks.com/topic/10690-problem-with-specifying-directory-when-using-file_get_content/#findComment-39891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.