473,382 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

how to create directory+subdirectory

hi
i'm desperate... i'm trying this for 2 days now... so if anyone can help -
please.

i have upload form in which users can choose TYPE of file they are uploading
(graphic/text/music) - and STATUS of that file (draft/finished). So, my
upload script is getting:
- $_FILE field,
- TYPE of file (it is string representing "DIRECTORY")
- STATUS of file (it is string representing "SUBDIRECTORY")

i cannot find working function or script to upload file to
"DIRECTORY/SUBDIRECTORY/" if that 2 dirs doesn' exist.

how can i create 2 dirs ? i tried recursively...
=================================================

function mkdirs($dir, $mode = 0777, $recursive = true) {
if( is_null($dir) || $dir === "" ){
return FALSE;
}
if( is_dir($dir) || $dir === "/" ){
return TRUE;
}
if( mkdirs(dirname($dir), $mode, $recursive) ){
return mkdir($dir,0777); // the default chmod
}
return FALSE;
}
==================================================

but it only creates first one, but not other (subdirectory) - like created
dir doesn't have permissions ??

anyone?

Jan 23 '06 #1
4 5837
On Mon, 23 Jan 2006 09:24:10 +0100, tomek wrote:
hi
i'm desperate... i'm trying this for 2 days now... so if anyone can help -
please.

i have upload form in which users can choose TYPE of file they are uploading
(graphic/text/music) - and STATUS of that file (draft/finished). So, my
upload script is getting:
- $_FILE field,
- TYPE of file (it is string representing "DIRECTORY")
- STATUS of file (it is string representing "SUBDIRECTORY")

i cannot find working function or script to upload file to
"DIRECTORY/SUBDIRECTORY/" if that 2 dirs doesn' exist.

how can i create 2 dirs ? i tried recursively...
=================================================

function mkdirs($dir, $mode = 0777, $recursive = true) {
if( is_null($dir) || $dir === "" ){
return FALSE;
}
if( is_dir($dir) || $dir === "/" ){
return TRUE;
}
if( mkdirs(dirname($dir), $mode, $recursive) ){
return mkdir($dir,0777); // the default chmod
}
return FALSE;
}
==================================================

but it only creates first one, but not other (subdirectory) - like created
dir doesn't have permissions ??

anyone?


have you got safe mode enabled? won't work then.
Jan 23 '06 #2
> >
how can i create 2 dirs ? i tried recursively...
=================================================
but it only creates first one, but not other (subdirectory) - like created dir doesn't have permissions ??

anyone?


have you got safe mode enabled? won't work then.


how can i know is that safemode enabled and where can i enabe it?
Jan 23 '06 #3

"ToMeK" <t_***@hotmail.com> wrote in message
news:dr**********@ss405.t-com.hr...

how can i create 2 dirs ? i tried recursively...
=================================================
but it only creates first one, but not other (subdirectory) - like created dir doesn't have permissions ??

anyone?


have you got safe mode enabled? won't work then.


how can i know is that safemode enabled and where can i enabe it?


i just contacted my provider and he says that they cannot change "safe_mode"
tag.
he mention something about "create directories with my UID" ? can anyone
tell me more details on that? (UID)

thanks.

is there another way? maybe ftp?
Jan 23 '06 #4

"ToMeK" <t_***@hotmail.com> wrote in message
news:dr**********@ss405.t-com.hr...

"ToMeK" <t_***@hotmail.com> wrote in message
news:dr**********@ss405.t-com.hr...
> >
> > how can i create 2 dirs ? i tried recursively...
> > =================================================
> > but it only creates first one, but not other (subdirectory) - like created
> > dir doesn't have permissions ??
> >
> > anyone?
>
> have you got safe mode enabled? won't work then.


how can i know is that safemode enabled and where can i enabe it?


i just contacted my provider and he says that they cannot change
"safe_mode"
tag.
he mention something about "create directories with my UID" ? can anyone
tell me more details on that? (UID)


user id? it sould like he's referring to an ftp client thing
look. you have a function that creates one directory successfully.
sometimes you can create a whole path at once. it is possible you have to
create them nested one by one. so maybe you have to explode() the dir
string and walk through them one by one & chdir+mkdir. you could do it
recursively, or iteratively.
it's just another method.
you might also consider that you might need to chdir somewhere first before
you start your first mkdir, or at least prepend an absolute path like (what
was it?) $_SERVER[DOCUMENT_ROOT]. Otherwise, who knows where your created
directory will end up. and because of that, it might fail if it's in a
restricted area.

thanks.

is there another way? maybe ftp?

Feb 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lise | last post by:
Hi all .. I have a directory with several subdirectories and a number of files in each. These files are accessed by going to a web page and clicking in a listbox and navigating to the desired...
4
by: Bill | last post by:
Will IIS6.0 recognize a global.asa file located in a subdirectory on the webserver? I'd like a file that will execute whenever a file in the subdirectory is browsed - or, at least it is...
1
by: STeve | last post by:
Hey guys, I couldn't find any documentation on visual c# how to copy the contents of one directory to another directory (directory includes files and a few subdirectories -- that do not contain...
4
by: Amos Soma | last post by:
Does anyone know the easiest way, in C#, to copy all directories and files starting with some root directory? For example, how might I copy all files and directories starting with 'C:\Program...
8
by: RML | last post by:
hey guys, i am looking at this piece of code that lists numbers of files in a directory. i want to convert it so it lists the files in th directory that end with .doc. i cant seem to get it to...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
1
by: jayeshthakker | last post by:
how to generate directory & sub directory like comp0001 comp0001y001 comp0001y002 comp0001y003 comp0002 comp0002y001 comp0002y002
1
by: Claire | last post by:
Ive written a small string resource building utility that I send out to our translators. I have a setup project for each language we support, which picks out a group of 12 english resx files plus...
2
by: deepaks85 | last post by:
Dear All, I know how to display contents of any directory. But what if I need to print the directory, subdirectory and its contents? The output should be: Folder Subfolder - File1 ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.