wmguk Posted December 29, 2008 Share Posted December 29, 2008 Hi, I have a script but its a bit overkill i think... <?php // initiating vars $login = $_GET['login']; $user = $_GET['user']; $getpics = "var/www/vhosts/domain.co.uk/httpdocs/clients/getpics.php"; $newdir = "var/www/vhosts/domain.co.uk/httpdocs/clients/$login/getpics.php"; $thisdir = "httpdocs/clients"; $dir = $thisdir . DIRECTORY_SEPARATOR . $login; $ftp_user_name='XXX'; // PUT YOUR FTP USER HERE $ftp_user_pass='XXX'; // PUT YOUR FTP PASSWORD HERE // Connection $conn_id = ftp_connect('domain.co.uk'); // Change to your hostname if needed // authenticating $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // connecting if ($conn_id && $login_result) { if (!is_dir($dir) ){ // Creating the dir with the FTP user owner if (ftp_mkdir($conn_id, $dir)) { // upload a file copy("$getpics", "$newdir"); chmod($newdir,0775); } else { echo "<p class='footer'>Failed to create directory...</p>"; } } else { // At this point, the folder was created with FTP user permissions // upload a file copy("$getpics", "$newdir"); chmod($newdir,0775); }} // Close connection ftp_close($conn_id); ?> however for some reason I get this error: Warning: copy() [function.copy]: Unable to access var/www/vhosts/domain.co.uk/httpdocs/clients/getpics.php in /var/www/vhosts/domain.co.uk/httpsdocs/photographer/createadmin/create.php on line 31 Warning: copy(var/www/vhosts/domain.co.uk/httpdocs/clients/getpics.php) [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpsdocs/photographer/createadmin/create.php on line 31 Warning: chmod() [function.chmod]: Unable to access var/www/vhosts/domain.co.uk/httpdocs/clients/winning l/getpics.php in /var/www/vhosts/domain.co.uk/httpsdocs/photographer/createadmin/create.php on line 32 Warning: chmod() [function.chmod]: stat failed for var/www/vhosts/domain.co.uk/httpdocs/clients/winning l/getpics.php in /var/www/vhosts/domain.co.uk/httpsdocs/photographer/createadmin/create.php on line 32 Can anyone help me out? This is driving me mad! Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/ Share on other sites More sharing options...
rhodesa Posted December 29, 2008 Share Posted December 29, 2008 looks like you want absolute paths...not relative...so add a / to the front: $getpics = "/var/www/vhosts/domain.co.uk/httpdocs/clients/getpics.php"; $newdir = "/var/www/vhosts/domain.co.uk/httpdocs/clients/$login/getpics.php"; Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725357 Share on other sites More sharing options...
wmguk Posted December 29, 2008 Author Share Posted December 29, 2008 ah ha, thank you, ok, we are getting closer! i now get this error: Warning: copy() [function.copy]: open_basedir restriction in effect. File(/var/www/vhosts/domain.co.uk/httpdocs/clients/getpics.php) is not within the allowed path(s): (/var/www/vhosts/domain.co.uk/httpsdocs:/tmp) in /var/www/vhosts/domain.co.uk/httpsdocs/photographer/createadmin/create.php on line 31 Warning: chmod() [function.chmod]: Unable to access /var/www/vhosts/domain.co.uk/httpdocs/clients/winning l/getpics.php in /var/www/vhosts/domain.co.uk/httpsdocs/photographer/createadmin/create.php on line 32 Warning: chmod() [function.chmod]: open_basedir restriction in effect. File(/var/www/vhosts/domain.co.uk/httpdocs/clients/winning l/getpics.php) is not within the allowed path(s): (/var/www/vhosts/domain.co.uk/httpsdocs:/tmp) in /var/www/vhosts/domain.co.uk/httpsdocs/photographer/createadmin/create.php on line 32 Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725359 Share on other sites More sharing options...
rhodesa Posted December 29, 2008 Share Posted December 29, 2008 your hosting service only allows scripts in the httpsdocs folder...not the httpdocs folder Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725363 Share on other sites More sharing options...
wmguk Posted December 29, 2008 Author Share Posted December 29, 2008 ah no sorry - I'm running a VPS to which I have full Root control... I am accessing a script that is in https://www.domain.co.uk however the folders I am trying to MKDIR with are in http://www.domain.co.uk the MKDIR works fine, but the copy fails... Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725379 Share on other sites More sharing options...
rhodesa Posted December 29, 2008 Share Posted December 29, 2008 then in your php.ini file, add /var/www/vhosts/domain.co.uk/httpdocs to the open_basedir parameter Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725385 Share on other sites More sharing options...
wmguk Posted December 29, 2008 Author Share Posted December 29, 2008 Thanks for all your help on this, this is the first time ive looked at the php.ini file, where do I put the /var/www/vhosts/domain.co.uk/httpdocs I've just SSH'd and used VI to look at it, and I've found the basedir section, however there arent any existing web addresses... this is the php.ini found in the etc folder on my server. Thanks so far Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725387 Share on other sites More sharing options...
wmguk Posted December 29, 2008 Author Share Posted December 29, 2008 also, ive just noticed... the error is: open_basedir restriction in effect. File(/var/www/vhosts/domain.co.uk/httpdocs/clients/getpics.php) is not within the allowed path(s): (/var/www/vhosts/domain.co.uk/httpsdocs:/tmp) :/tmp on the end? is that normal as I thought that should display the directory where it is being copied in to? Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725397 Share on other sites More sharing options...
rhodesa Posted December 29, 2008 Share Posted December 29, 2008 the : separates a list of values the open_basedir restriction might be set by your hosting company. give their tech department a call, they should be able to tell you how to fix it Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725399 Share on other sites More sharing options...
wmguk Posted December 29, 2008 Author Share Posted December 29, 2008 hey, thanks again in my php.ini ive just checked and ive got safe_mode = off ..... open_basedir = off so does that mean it must be the hosting company who are over-riding that, ive set it all off and restarted apache, but it didnt make any difference... Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725451 Share on other sites More sharing options...
rhodesa Posted December 29, 2008 Share Posted December 29, 2008 probably...just give them a call Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-725498 Share on other sites More sharing options...
wmguk Posted December 30, 2008 Author Share Posted December 30, 2008 ah ha, they turned it off, and that part now works however the copy doesnt... $login = $_GET['login']; $getpics = "/var/www/vhosts/iwphoto.co.uk/httpsdocs/getpics.php"; $newdir = "/var/www/vhosts/iwphoto.co.uk/httpdocs/clients/$login/getpics.php"; copy("$getpics", "$newdir"); I've echo'd the $login and it is correct so thats ok, but the error message says: Warning: copy(/var/www/vhosts/domain.co.uk/httpdocs/clients/winning l/getpics.php) [function.copy]: failed to open stream: Permission denied in /var/www/vhosts/domain.co.uk/httpsdocs/photographer/createadmin/create.php on line 30 Any ideas? Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726102 Share on other sites More sharing options...
rhodesa Posted December 30, 2008 Share Posted December 30, 2008 as it states, you don't have permission. the owner you created getpics.php with must not match the web process. ssh into the system and run: chmod e+r /var/www/vhosts/iwphoto.co.uk/httpsdocs/getpics.php Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726588 Share on other sites More sharing options...
wmguk Posted December 31, 2008 Author Share Posted December 31, 2008 hi, I did that but I now get "invalid mode e+r" while Im trying to SSH the chmod.... I've checked via FTP and the file is 777 and the owner and group are the same as the owner and group creating the folder... this is so wierd! Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726823 Share on other sites More sharing options...
wmguk Posted December 31, 2008 Author Share Posted December 31, 2008 any thought as to why "copy" isnt working? can anyone point me in the right direction please? I'm totally lost Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726878 Share on other sites More sharing options...
rhodesa Posted December 31, 2008 Share Posted December 31, 2008 my bad. i read the error wrong. the problem isn't with the 'reading' part of the copy, it's the writing part. -what are the permissions on /var/www/vhosts/domain.co.uk/httpdocs/clients/ ? -does the script successfully create /var/www/vhosts/domain.co.uk/httpdocs/clients/$login/ before the copy? -if so, what are the permissions on /var/www/vhosts/domain.co.uk/httpdocs/clients/$login/ after it is created? Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726880 Share on other sites More sharing options...
wmguk Posted December 31, 2008 Author Share Posted December 31, 2008 -what are the permissions on /var/www/vhosts/domain.co.uk/httpdocs/clients/ ? Its set to 777 -does the script successfully create /var/www/vhosts/domain.co.uk/httpdocs/clients/$login/ before the copy? -if so, what are the permissions on /var/www/vhosts/domain.co.uk/httpdocs/clients/$login/ after it is created? It does and it sets to 755 I've got a different script afterwards that allows users to upload images in to the directory that is created, and that works fine, i can upload the getpics.php file using ftp but I simply cant run the copy script Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726882 Share on other sites More sharing options...
rhodesa Posted December 31, 2008 Share Posted December 31, 2008 very weird...what if you do this instead...does it work: $login = $_GET['login']; $getpics = "/var/www/vhosts/iwphoto.co.uk/httpsdocs/getpics.php"; $newdir = "/var/www/vhosts/iwphoto.co.uk/httpdocs/clients/$login/getpics.php"; file_put_contents($newdir,file_get_contents("$getpics")); Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726886 Share on other sites More sharing options...
wmguk Posted December 31, 2008 Author Share Posted December 31, 2008 hmmmm ok, just tried that and i get: Warning: file_put_contents(/var/www/vhosts/domain.co.uk/httpdocs/clients/winning l/getpics.php) [function.file-put-contents]: failed to open stream: Permission denied in /var/www/vhosts/domain.co.uk/httpsdocs/photographer/createadmin/create.php on line 37 Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726901 Share on other sites More sharing options...
rhodesa Posted December 31, 2008 Share Posted December 31, 2008 does /var/www/vhosts/domain.co.uk/httpdocs/clients/winning l/getpics.php exist already? Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726905 Share on other sites More sharing options...
wmguk Posted December 31, 2008 Author Share Posted December 31, 2008 Just checked it via ftp, and it doesnt exist already Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726908 Share on other sites More sharing options...
rhodesa Posted December 31, 2008 Share Posted December 31, 2008 i don't know what else to say. everything seems in order. i would contact your hosting company again, as they can get on the physical system and try to debug a solution Link to comment https://forums.phpfreaks.com/topic/138733-problem-with-mkdir/#findComment-726911 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.