Jump to content

Recommended Posts

Hey guys,

 

I'm trying to run a simple script.

 

The Aim:

 

Page Loads,

 

if the directory exists, do nothing....

 

if not then create the directory, as 777 and copy a file to it.

 

this is my code

<?php
session_start(); 
if (!isset($_SESSION['myusername'])) {
    header("location:index.php");
    exit; } 
$user = $_SESSION['myusername'];
$login = $_POST['login'];
include "../scripts/connection.php";
include "../scripts/ftpaccess.php";
$_GET['login'] = $login;
include "create.php" ;
?>

 

//THIS IS THE ONCLICK FUNCTION - WHICH WORKS TO RUN A POP UP

<script language="JavaScript" type="text/javascript">
function ftpaccess()
{
 var popurl="<? echo $ftpacc ; ?>"
 winpops=window.open(popurl,"","width=600,height=400,scrollbars,menubar,resizable,")
}

</script>

 

<?PHP
//This is ../scripts/ftpaccess.php

$ftpuser = "ftpdomain";
$ftppass = "imagine";
$ftplocation = "ftp.domain.co.uk/httpdocs/clients";
$ftpacc = "ftp://$ftpuser:$ftppass@$ftplocation/$login" ;
$incdir = "http://www.domain.co.uk/clients/create.php" ;
?>

 

<?php
// THIS IS create.php

$thisdir = "/var/www/vhosts/domain.co.uk/httpdocs/clients";
$login = $_GET['login'];

$getpics = "/var/www/vhosts/domain.co.uk/httpdocs/clients/getpics.php";
$newdir = "/var/www/vhosts/domain.co.uk/httpdocs/clients/$login/getpics.php";

if (is_dir($thisdir ."/$login") )
{
}
else
{
if(mkdir($thisdir ."/$login" , 777, true)){
}

else
{
   echo "<p class='footer'>Failed to create directory... <br> Contact <a href='mailto:drew@wicked-websites.co.uk'>Wicked Websites</a></p>";
} 

copy("$getpics", "$newdir"); }
?>

 

However for some reason, it is creating as 755, I'm always getting permission denied when trying to upload to the folder, and I was just wondering if there is a much simpler version to upload files?

i did look at chmod, but i thought that specifying it on the mkdir would be the same...

 

i just thought maybe i was doing something totally stupid or there was a simple section of code to do what im doing in 3 pages of includes lol...

 

it is working because it creates the folder but it creates it with 0755 not 0777

The default permissions for mkdir() are 0777 but this is not always (usually) the case.

Its a wierd one but chmod() should allow you to change the permissions.

 

You could also create directories using exec()

exec("mkdir /path/folder");

exec("chmod -R 777 /path/folder");

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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