RE: [PHP] Uploading files without saving them

2008-06-23 Thread Boyd, Todd M.
 -Original Message-
 From: James Colannino [mailto:[EMAIL PROTECTED]
 Sent: Monday, June 23, 2008 3:48 PM
 To: php-general@lists.php.net
 Subject: [PHP] Uploading files without saving them
 
 Hey everyone.  Here's a simple question.  I'd like to be able to
import
 information from a text file located on the client without actually
 saving it on the server; that is, I simply want to read the data into
 memory on the server, without actually saving it to a file.
 
 I've been googling around to learn about uploading files via PHP, but
 haven't found anything yet (I could save the file to a temporary
 location and delete it when finished, but I'd prefer not to have to do
 this if at all possible.)
 
 Anyone have any ideas?  Thanks! :)

IIRC, if you never move it out of PHP's defaulted temporary storage
sandbox, it will eventually be wiped. When files are uploaded via PHP,
they must explicitly be moved into the active file system.

HTH,


Todd Boyd
Web Programmer




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Uploading files without saving them

2008-06-23 Thread James Colannino

Boyd, Todd M. wrote:


IIRC, if you never move it out of PHP's defaulted temporary storage
sandbox, it will eventually be wiped. When files are uploaded via PHP,
they must explicitly be moved into the active file system.


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?


James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

Black holes are where God divided by zero. --Steven Wright

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Uploading files without saving them

2008-06-23 Thread James Colannino

Nitsan Bin-Nun wrote:

PHP uses randomaly name for each of them (during the upload to the 
temporary directory), when its done PHP moves the file to the objective 
location, i dont think you will obstacle filename problems.


Ah, excellent!  Thanks :)

James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

Black holes are where God divided by zero. --Steven Wright

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Uploading files without saving them

2008-06-23 Thread Daniel Brown
On Mon, Jun 23, 2008 at 6:05 PM, James Colannino [EMAIL PROTECTED] 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.

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Uploading files without saving them

2008-06-23 Thread Shawn McKenzie

Daniel Brown wrote:

On Mon, Jun 23, 2008 at 6:05 PM, James Colannino [EMAIL PROTECTED] 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'?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Uploading files without saving them

2008-06-23 Thread Daniel Brown
On Mon, Jun 23, 2008 at 8:17 PM, Shawn McKenzie [EMAIL PROTECTED] wrote:

 Oooo...  where can I get this 'summer.jpg'?

It's an Easter Egg embedded in the $_FILES array under an
undocumented hidden key.

?php

move_uploaded_file($_FILES['BITE_MY_SHINY_METAL_ASS'],dirname(__FILE__).'/summer.jpg');
?

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php