Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #9336
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "J.O. Aho" <user@example.net> |
| Newsgroups | comp.lang.php |
| Subject | Re: mkdir no such file or directory |
| Date | Wed, 15 May 2013 06:34:49 +0200 |
| Lines | 63 |
| Message-ID | <avghj9F68pvU1@mid.individual.net> (permalink) |
| References | <a47b8f8a-1bd8-45c2-8edc-dd5fa2934203@googlegroups.com> <1d2ec34d-5532-4576-bcce-8c0cb77637ab@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net GySTNI+4V2vm2vrjbs16+gl3xm4zRoQ1Auf6nYuxitf19tVFXJ |
| Cancel-Lock | sha1:+ISAA30HzsIxqHtC3lE/K0gbVVk= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130408 Thunderbird/17.0.5 |
| In-Reply-To | <1d2ec34d-5532-4576-bcce-8c0cb77637ab@googlegroups.com> |
| Xref | csiph.com comp.lang.php:9336 |
Show key headers only | View raw
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
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
mkdir no such file or directory "Bhushan N.N" <bhushan154@gmail.com> - 2013-05-14 20:04 -0700
Re: mkdir no such file or directory "Bhushan N.N" <bhushan154@gmail.com> - 2013-05-14 20:06 -0700
Re: mkdir no such file or directory "J.O. Aho" <user@example.net> - 2013-05-15 06:34 +0200
Re: mkdir no such file or directory Richard Yates <richard@yatesguitar.com> - 2013-05-14 21:37 -0700
Re: mkdir no such file or directory Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-05-14 22:39 -0600
Re: mkdir no such file or directory Arno Welzel <usenet@arnowelzel.de> - 2013-05-15 12:05 +0200
Re: mkdir no such file or directory The Natural Philosopher <tnp@invalid.invalid> - 2013-05-15 11:23 +0100
Re: mkdir no such file or directory Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-15 12:38 +0000
Re: mkdir no such file or directory Robert Heller <heller@deepsoft.com> - 2013-05-15 08:51 -0500
Re: mkdir no such file or directory "Bhushan N.N" <bhushan154@gmail.com> - 2013-05-15 08:19 -0700
Re: mkdir no such file or directory "Bhushan N.N" <bhushan154@gmail.com> - 2013-05-15 08:20 -0700
Re: mkdir no such file or directory Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-15 18:37 +0200
Re: mkdir no such file or directory "Bhushan N.N" <bhushan154@gmail.com> - 2013-05-15 16:20 -0700
Re: mkdir no such file or directory Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-15 23:55 +0000
Re: mkdir no such file or directory Robert Heller <heller@deepsoft.com> - 2013-05-15 13:44 -0500
Re: mkdir no such file or directory Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-15 21:31 +0200
csiph-web