Jump to content

Stupid MKDIR Error - Simple file upload script?


wmguk

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:[email protected]'>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");

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.