eppievojt Posted February 13, 2007 Share Posted February 13, 2007 I created a directory using mkdir, setting permissions to 0777 - directory shows up right where it is supposed to. Unfortunately, whenever I try to run my upload script to this directory, it kicks out. Same thing if I try to create a simple txt file. It won't work. There's not a problem with the scripts, because if I change the directory to load to, they work fine. Why are the directories I'm creating using PHP unusable? Any ideas? Quote Link to comment Share on other sites More sharing options...
effigy Posted February 13, 2007 Share Posted February 13, 2007 What is the owner/group of this directory? It may not be open to the owner/group that Apache runs as. Quote Link to comment Share on other sites More sharing options...
eppievojt Posted February 13, 2007 Author Share Posted February 13, 2007 The directory it's trying to upload to is created by Apache using mkdir() - it's part of the same script. Here's some code for a most simple test to see if the directory is working properly: <?php $targetdir="/var/www/vhosts/domain.net/httpdocs/mydir/"; $newdir="103457/"; $targetdir=$targetdir.$newdir; if(!(file_exists($targetdir))){ mkdir($targetdir,0777,TRUE); } $test=$targetdir."test.txt"; $fr = fopen($test,'w'); if(!$fr) { echo "Could not create the test file!"; exit; } fputs($fr, "text"); fclose($fr); ?> mydir is NOT owned by Apache, but there's no problem in creating the directory. The problem is once the directory is made, nothing writes to it. I use the exact same code on another domain with the same folder structure and there are no problems, which is what is very frustrating. This was supposed to be an easy port over from a test server. Thanks for any assistance you can render. Quote Link to comment Share on other sites More sharing options...
eppievojt Posted February 13, 2007 Author Share Posted February 13, 2007 ...also, if I leave off the $newdir variable and just upload to the parent directory (not owned by Apache), the file upload works fine... same with the test script. It's just the directories I create in the script using mkdir() that aren't working. Quote Link to comment Share on other sites More sharing options...
effigy Posted February 13, 2007 Share Posted February 13, 2007 Does this server have the same platform as the test server? What about OS? Is your error reporting cranked up for this script? What errors are you getting? Since you're using the full path, there could be underlying permission issues--a missing "x". Have you tried to chdir to that directory, then create it relatively? Quote Link to comment Share on other sites More sharing options...
eppievojt Posted February 14, 2007 Author Share Posted February 14, 2007 Does this server have the same platform as the test server? What about OS? Is your error reporting cranked up for this script? What errors are you getting? Since you're using the full path, there could be underlying permission issues--a missing "x". Have you tried to chdir to that directory, then create it relatively? It's actually running on the same server, just ported over from a different domain where it was tested, so the platform and OS can't be issues. I'm not sure how to crank up my error checking, but I do know that I have to use full paths, because virtual paths are disabled on this server (phpinfo check). If I manually create the directory from my ftp client, the script works fine. I'm pulling my hair out over this. Quote Link to comment Share on other sites More sharing options...
btherl Posted February 14, 2007 Share Posted February 14, 2007 Can you add this after you make the directory: printf("%o\n", fileperms($targetdir)); I just tried a mkdir() here, and the permissions of the created directory did not match those I specified in the call. Quote Link to comment Share on other sites More sharing options...
effigy Posted February 14, 2007 Share Posted February 14, 2007 Ah, that's right. Check out umask. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 14, 2007 Share Posted February 14, 2007 <?php $targetdir=""; $newdir="103457/"; $targetdir=$targetdir.$newdir; if(!(file_exists($targetdir))){ mkdir($targetdir); } $test=$targetdir."test.txt"; $fr = fopen($test,'w'); if(!$fr) { echo "Could not create the test file!"; exit; } fputs($fr, "text"); fclose($fr); ?> try this tell us what happens should make a dir and file within it? for any problams setting the folder to 0777 here you go m8. <?php $targetdir=""; $newdir="103457/"; $targetdir=$targetdir.$newdir; @chmod($targetdir, 007); if(!(file_exists($targetdir))){ mkdir($targetdir); } $test=$targetdir."test.txt"; $fr = fopen($test,'w'); if(!$fr) { echo "Could not create the test file!"; exit; } fputs($fr, "text"); fclose($fr); ?> Quote Link to comment Share on other sites More sharing options...
eppievojt Posted February 14, 2007 Author Share Posted February 14, 2007 Still sitting here with the same problem. None of the above has had any impact. As an update, I ran phpinfo() and realized that this new domain has safe_mode ON locally, even though the master setting is Off. My suspicion is that this is the problem... too bad I don't know how to fix it and Godaddy has the world's worst support system. Anybody know what I need to modify to change the local setting? Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 14, 2007 Share Posted February 14, 2007 my second post should work ok. <?php $targetdir=""; $newdir="103457/"; $targetdir=$targetdir.$newdir; @chmod($targetdir, 007); if(!(file_exists($targetdir))){ mkdir($targetdir); } $test=$targetdir."test.txt"; $fr = fopen($test,'w'); if(!$fr) { echo "Could not create the test file!"; exit; } fputs($fr, "text"); fclose($fr); ?> godaddy is the worst hosting for a php programmer change to a decent hosting acount ok. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 14, 2007 Share Posted February 14, 2007 "Godaddy has the world's worst support system." I hate to bump this, but GoDaddy has the BEST support of any host I have ever used. They have 24 hour phone support, and in the 3 years I've been using them I have never had it take more than one short call to get a problem fixed. How are you having trouble getting support from them? Quote Link to comment Share on other sites More sharing options...
linux_win Posted February 15, 2007 Share Posted February 15, 2007 Hello... i got a problem when i want to delete or rename my directory folder that i create first. error msg : permission denied . i think that server i use it is windows not linux...hmmm.... i try any ways to solve it...eg: 1. i try to mkdir("$filename", 0777); //error 2. @chmod("$filename",0777);// still error mkdir("$filename"); 3.@chmod($filename,0777); @unlink($filename) //error gezz im dizzy now...pls help me Quote Link to comment 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.