PHP mkdir Driving me crazy!!  | | |
March 8th, 2007, 03:54 PM
|
#1 (permalink)
| | Senior Member
Join Date: Jan 2004 Location: London UK
Posts: 527
| PHP mkdir Driving me crazy!!
the following PHP script works perfect on my home PC -
if($totalRows_info == 0) {
$bandfolder = "../bands/" . $_POST['BandName'];
mkdir($bandfolder,0777,TRUE);
$password=$_POST['password'];
when executed from the server no folder is created.
I changed permissions on the servers 'bands' folder to 777, and still new folders are not created.
the folder 'bands' is located in the servers root directory.
spent an hour on the phone to the servers tech support - they cant help!
can any of you guys help?
I hope so
thanks
__________________ Signature images disabled. |
| |
March 8th, 2007, 04:52 PM
|
#2 (permalink)
| | Banned
Join Date: Jan 2004 Location: Earth
Posts: 420
|
It probably has something to do with: "../bands/" a parent path. There are security reasons why parent paths on some servers are restricted.
Try writing to the same directory first to make sure there is no error there. Then try different combos with the path... ie: the whole path: http://www.yourweb.com/bands/ or /bands/ or whatever... |
| |
March 8th, 2007, 05:02 PM
|
#3 (permalink)
| | Senior Member
Join Date: Jan 2004 Location: London UK
Posts: 527
|
thanks
Tried the whole path, tried /bands/
still - no new folder
aahhhhrggg |
| |
March 8th, 2007, 05:20 PM
|
#4 (permalink)
| | Banned
Join Date: Jan 2004 Location: Earth
Posts: 420
|
try: "\\bands"
Just a thought: I know Windows handles directories differently from Linux.
Last edited by Iturea : March 8th, 2007 at 05:41 PM.
|
| |
March 8th, 2007, 06:40 PM
|
#5 (permalink)
| | Senior Member
Join Date: Jan 2004 Location: London UK
Posts: 527
|
thanks again, the server is on a linux system, my home comp is on an apache server. tried this -
if($totalRows_info == 0) {
$bandfolder = "//bands/" . $_POST['BandName'];
mkdir($bandfolder,0777,TRUE);
$password=$_POST['password'];
$message = "User " . $_POST['BandName'] . " has been added to the database";
then tried this -
if($totalRows_info == 0) {
$bandfolder = "\\bands\\" . $_POST['BandName'];
mkdir($bandfolder,0777,TRUE);
even this didnt work -
if($totalRows_info == 0) {
$bandfolder = $_POST['BandName'];
mkdir($bandfolder,0777,TRUE);
I really dont know what else to try, I need these folders creatinging or re-do allot of code that relies on it and im running out of time  |
| |
March 8th, 2007, 08:05 PM
|
#6 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,552
|
Try setting $bandfolder to something static and see if that works.
$bandfolder = "bands/test";
__________________
Signatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
|
| |
March 8th, 2007, 10:46 PM
|
#7 (permalink)
| | Junior Member
Join Date: Dec 2006 Location: Alabama
Posts: 2
|
Another idea - Try creating /bandfolder in a permissive directory first, where it WILL work; then try copying/moving it over to /bands, see if /bands will accept a copy or a move operation where it will not accept a mkdir. Good luck, and please let your faithful fans know what works, when it works! |
| |
March 9th, 2007, 04:43 AM
|
#8 (permalink)
| | Senior Member
Join Date: Jan 2004 Location: London UK
Posts: 527
|
ok this is getting silly
I created a new php file that just contained the following code -
<?
mkdir(bands/test,0777,TRUE);
?>
uploaded it to server and ran it - NOTHING !!!
I double checked folder 'bands' permissions - 777 so its not that.
Its got to be a server problem right? |
| |
March 9th, 2007, 05:47 AM
|
#9 (permalink)
| | Senior Member
Join Date: Jan 2004 Location: London UK
Posts: 527
|
OK
I logged in using Putty via SSH and ran command mkdir bands/test
this worked fine and created the folder
Its obviously a permissions issue, I cant change the root folder permissions (nor would I want to)
Is there a way to get php to log into the account, make the directory and log out? |
| |
March 9th, 2007, 07:46 AM
|
#10 (permalink)
| | Senior Member
Join Date: Jan 2004 Location: London UK
Posts: 527
|
I have solved the problem using ftp access, not what i wanted, but it works -
<?php
$ftp_server = "*******";
$ftp_user_name = "********";
$ftp_user_pass = "********";
$dir = $_POST['BandName'];
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
ftp_mkdir($conn_id, $dir);
}
// close the FTP stream
ftp_close($conn_id);
?>
saves me allot of hassle but im not sure how secure this script is, I created a new ftp access account restricting access to the bands folder only.
hope its safe!!
thanks for the help
Last edited by reiss : March 9th, 2007 at 08:05 AM.
|
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |