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 #181410 is a reply to message #181409] Wed, 15 May 2013 16:37 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Bhushan N.N wrote:

> ie, if my website is called example, the structure will be
>
> example
> index.php
> upload.php
> search.php
> uploads
> 12209214
> somefile.txt
> 31231203
> otherfile.txt
> about.php
> contact.php

Please learn how to post properly on Usenet. Avoid Google Groups in favor
of a locally installed newsreader application if possible.

The problem here is that you are falsely assuming that “/” refers to the
document root. Instead, it refers to the *filesystem* root, where you/the
Web server SHOULD NOT have write access. As “uploads” is a directory on the
same level as upload.php, it is probably easiest for you just to omit the
leading “/”.

However, it would be safest to refer to the document root explicitly, like

$_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $value

(As you can see, it does not make sense to concatenate '/uploads' . '/' when
you can just write '/uploads/'.)

It also does not make a lot of sense to create a directory for every second
of upload since epoch, using time(). If you need to group uploads by date
for quick access, I suggest you use year/month/date instead. That said, you
can rather easily filter an array of file information, so unless there is a
chance that on different times people would upload files with the *same*
name where they do *not* want to overwrite the old version, you do not need
that directory structure.

However, in a multi-user application another piece is missing in any case:
You need a way to differentiate between the files of users or one user could
overwrite the file of another. Using time() _cannot_ prevent that from
happening, because there is the possibility of concurrent access.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
[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: Sun Dec 01 04:15:23 GMT 2024

Total time taken to generate the page: 0.04732 seconds