Page 1 of 1

what is tmp_name in a file ??

Posted: Fri Aug 04, 2017 2:49 pm
by gautamz07
Hey guys , i was just going through the following code for php file upload(i am just posting a small snippet):

Code: Select all

<?php
$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
        // basename() may prevent filesystem traversal attacks;
        // further validation/sanitation of the filename may be appropriate
        $name = basename($_FILES["pictures"]["name"][$key]);
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}
?>
I know that the array has a property `name` , `size` and `type`, But what exactly is `tmp_name` ? can somebody explain ?

Thank you.
Gautam.

Re: what is tmp_name in a file ??

Posted: Fri Aug 04, 2017 5:41 pm
by requinix