wmguk Posted August 20, 2008 Share Posted August 20, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/120518-stupid-mkdir-error-simple-file-upload-script/ Share on other sites More sharing options...
JonnoTheDev Posted August 20, 2008 Share Posted August 20, 2008 You need to use 0777 instead of 777 in your mkdir() function Quote Link to comment https://forums.phpfreaks.com/topic/120518-stupid-mkdir-error-simple-file-upload-script/#findComment-621040 Share on other sites More sharing options...
wmguk Posted August 20, 2008 Author Share Posted August 20, 2008 ah sorry, thats a typo, it was 0777, but after that didnt work i tried 777 instead... Quote Link to comment https://forums.phpfreaks.com/topic/120518-stupid-mkdir-error-simple-file-upload-script/#findComment-621042 Share on other sites More sharing options...
JonnoTheDev Posted August 20, 2008 Share Posted August 20, 2008 Check out the chmod() function Quote Link to comment https://forums.phpfreaks.com/topic/120518-stupid-mkdir-error-simple-file-upload-script/#findComment-621043 Share on other sites More sharing options...
wmguk Posted August 20, 2008 Author Share Posted August 20, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/120518-stupid-mkdir-error-simple-file-upload-script/#findComment-621046 Share on other sites More sharing options...
JonnoTheDev Posted August 20, 2008 Share Posted August 20, 2008 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"); Quote Link to comment https://forums.phpfreaks.com/topic/120518-stupid-mkdir-error-simple-file-upload-script/#findComment-621051 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.