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!

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";

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

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...

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 :)

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?

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...

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?

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?

-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

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"));

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

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.