FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » mkdir no such file or directory
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: mkdir no such file or directory [message #181390 is a reply to message #181388] Wed, 15 May 2013 04:34 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
On 15/05/13 05:06, Bhushan N.N wrote:

NOTE: Don't top post, reply inline. If not replying to the whole post,
then remove those parts you don't reply to.


>> I want to create a directory using mkdir. But I get "No such file or directory" error.

mkdir() will only give true or false depending on if it can create the
directory or not.


>> Below is the code I am using.
>> $filelocation = "/uploads/" . "/" . time();

Usually the user as who the process is run as (web server user or a
normal user) will not have the right to make a directory in the root
file system (path: /), but we assume you have full control of the web
server and can create the directory /uploads and have already made it,
then you need to allow the web server/normal user as whom the php script
is run as to have rwx on that directory.


>> Can some one please tell me what I am doing wrong?
>> I also tried manually creating the uploads folder. Still the same error. Any help will be much appreciated.
>
> Here is my code again
>
> $filelocation = "/uploads/" . "/" . time();
> if (mkdir($filelocation,0777,true))
> {
> echo("Thank you for uploading the file.");
> }
> else
> {
> echo("Oops error uploading file.");
> }

$path = "/uploads";
$dir = time();

if(file_exists($path)) {
if(file_exists($path."/".$dir)) {
echo "directory {$path}/{$dir} already exists";
} else {
if(mkdir($path."/".$dir,0777,true)) {
echo "Created {$path}/{$dir}";
} else {
echo "Can't create {$path}/{$dir}";
}
}
} else {
echo "{$path} is missing";
}

This is a simple check with a bad way of echoing out results, this don't
check if the file really is a directory, is_dir() will tell you that if
you want to make the check more complete, I suggest you look at
Exceptions instead of just echo everything.

--

//Aho
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Booleans compared to strings
Next Topic: isset not working with select
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 08:32:14 GMT 2024

Total time taken to generate the page: 0.03907 seconds