tbarbedo Posted March 16, 2009 Share Posted March 16, 2009 Just trying to create a standard directory with PHP.. <?php if(mkdir("path/to/my/dir")) { echo "dir created!"; } else { die("error!"); } ?> Getting the following error message... Warning: mkdir() [function.mkdir]: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\makedir.php on line 2 Can someone please help me?? I can't figure this out...Thanks in advance!! Link to comment https://forums.phpfreaks.com/topic/149605-solved-simple-problem-with-mkdirplease-help-me/ Share on other sites More sharing options...
.josh Posted March 16, 2009 Share Posted March 16, 2009 looks like you're running your script in a windows environment, so you need to format your path/to/dir to follow windows format. Link to comment https://forums.phpfreaks.com/topic/149605-solved-simple-problem-with-mkdirplease-help-me/#findComment-785592 Share on other sites More sharing options...
tbarbedo Posted March 16, 2009 Author Share Posted March 16, 2009 Thanks for the response.. Yes I am running this in a Windows environment... Not sure exactly what you mean by formatting the path to Windows..could you please elaborate a little further? Link to comment https://forums.phpfreaks.com/topic/149605-solved-simple-problem-with-mkdirplease-help-me/#findComment-785593 Share on other sites More sharing options...
trq Posted March 16, 2009 Share Posted March 16, 2009 Linux paths look like this/is/a/dir/path Windows paths look like this\is\a\dir\path Link to comment https://forums.phpfreaks.com/topic/149605-solved-simple-problem-with-mkdirplease-help-me/#findComment-785595 Share on other sites More sharing options...
tbarbedo Posted March 16, 2009 Author Share Posted March 16, 2009 I figured that's what he mean but I tried replacing 'path/to/dir' with 'path\to\dir' and I get an 'Invalid Argument' error so I thought maybe he meant something else... Can you give me any ideas on how to correct this problem I am having? Link to comment https://forums.phpfreaks.com/topic/149605-solved-simple-problem-with-mkdirplease-help-me/#findComment-785598 Share on other sites More sharing options...
trq Posted March 16, 2009 Share Posted March 16, 2009 As the error states 'No such file or directory', I would suggest making sure you are passing mkdir a valid path. Link to comment https://forums.phpfreaks.com/topic/149605-solved-simple-problem-with-mkdirplease-help-me/#findComment-785609 Share on other sites More sharing options...
.josh Posted March 16, 2009 Share Posted March 16, 2009 you also need to escape the backslashes so php doesn't think you're trying to pass special chars Link to comment https://forums.phpfreaks.com/topic/149605-solved-simple-problem-with-mkdirplease-help-me/#findComment-785629 Share on other sites More sharing options...
exally Posted March 16, 2009 Share Posted March 16, 2009 \\path\\to\\dir Link to comment https://forums.phpfreaks.com/topic/149605-solved-simple-problem-with-mkdirplease-help-me/#findComment-785648 Share on other sites More sharing options...
tbarbedo Posted March 16, 2009 Author Share Posted March 16, 2009 Thanks exally.... \\path\\to\\dir did it for me Thanks for the help everyone! Link to comment https://forums.phpfreaks.com/topic/149605-solved-simple-problem-with-mkdirplease-help-me/#findComment-785781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.