Re: Uploading files without saving them

From: Date: Tue, 24 Jun 2008 00:17:42 +0000
Subject: Re: Uploading files without saving them
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-275869@lists.php.net to get a copy of this message
Daniel Brown wrote:
On Mon, Jun 23, 2008 at 6:05 PM, James Colannino <james@colannino.org> wrote:
Ah, I see. What would happen if two people just happened to upload files with the same filename at the same time? Would one stomp over the other, or does PHP have mechanisms to handle that sort of situation?
    Todd is correct.  When you upload a file, it's saved to a
temporary directory with a unique filename. Thus, if six people upload the file summer.jpg, you may instead see on the server side:
        /tmp/PHPf983D93j
        /tmp/PHPOg4ji23
        /tmp/PHPeklS83q
    .... and so on.
    Further, as Todd mentioned, unless you explicitly call
move_uploaded_files() or perform a similar action, the file will be deleted as soon as the Apache child process dies --- which happens as soon as script execution completes.
    Keep in mind that this is all assuming that you're using Apache on
a *NIX-like system. If you're using IIS, Windows, or anything else, your mileage may vary. Oooo... where can I get this 'summer.jpg'?


« previous php.general (#275869) next »