Jump to content

Problem with MKdir...


wmguk

Recommended Posts

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

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

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

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

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

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

-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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.