By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,968 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,968 IT Pros & Developers. It's quick & easy.

how to create and open directory in php directory dynamically?

P: 19
here i have error as,"Undefined index: $opdir in C:\wamp\www\mumtaj\sathya\directory.php on line 15
Directory does not exist"
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $dir=(mkdir("C:\wamp\www\upload3" , 0777));
  3. if($dir)
  4. {
  5.    echo "Directory has been created successfully...";
  6. }
  7. else
  8. {
  9.    echo "Failed to create directory...";
  10. }
  11.  
  12. $opdir=opendir("C:\wamp\www\upload3");
  13. $uploaddir = $_SERVER['$opdir'];        //Now here is the problem, what to give in the //place of '$opdir' ..
  14. echo (file_exists($uploaddir) && is_dir($uploaddir)) ? 'Directory path ok' : 'Directory does not exist';
  15. ?>
  16.  
May 6 '12 #1
Share this Question
Share on Google+
5 Replies


100+
P: 1,059
replace your all \ with \\ or instead just use / your problem would be solved
May 7 '12 #2

P: 19
same problem exist in that after that change too.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $dir=(mkdir("C:/wamp/www/upload34" , 0777));
  3. if($dir)
  4. {
  5.    echo "Directory has been created successfully...";
  6. }
  7. else
  8. {
  9.    echo "Failed to create directory...";
  10. }
  11.  
  12. $opdir=opendir("C:/wamp/www/upload34");
  13.  
  14. $uploaddir = $_SERVER['$opdir'];        //Now here is the problem, what to give in the //place of '$opdir' ..
  15. echo (file_exists($uploaddir) && is_dir($uploaddir)) ? 'Directory path ok' : 'Directory does not exist';
  16. ?>
  17.  
May 7 '12 #3

P: 4
if ur using windows or linux?
May 8 '12 #4

100+
P: 1,059
start fixing from line 12

at line 12 you have
Expand|Select|Wrap|Line Numbers
  1. $opdir=opendir("C:/wamp/www/upload34"); 
  2. //$opdir a resource, resource of directory.
  3.  
  4.  
line 14
Expand|Select|Wrap|Line Numbers
  1. $uploaddir = $_SERVER['$opdir'];        //Now here is the problem, what to give in the //place of '$opdir' ..
  2.  
  3. //here uploaddir would get resource $_SERVER don't exists. What does it contain nothing. 
  4.  
read documentation for every function you have used in your php code
May 8 '12 #5

P: 19
i use windowsXP and WAMP package...
May 22 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.