Does tmp_name disappear after move_uploaded_file is used?
<p>I have this page where you can send message to multiple people and attach files into it...</p>

<p>Here is my code</p>

<pre><code>&lt;?php
    session_start();
    $inboxfrom = $_SESSION['loginusername'];
    $inboxto = $_POST['inboxto'];
    $inboxsubject = $_POST['inboxsubject'];
    $inboxcontent = $_POST['inboxcontent'];
    $inboxtime = date('g:i A', time()+(6*60*60));
    $inboxdate = date('Y-m-d', time()+(6*60*60));
    mysql_connect("127.0.0.1", "root", "")or die("Cannot Connect toDb");
    mysql_select_db("Abbot_db");
    $count = 0;
    function generateRandomString($length = 8){    
        $string = ""; 
        $possible = "0123456789bcdfghjkmnpqrstvwxyz"; //character that can be used 
        for($i=0;$i &lt; $length;$i++){ 
            $char = substr($possible, rand(0, strlen($possible)-1), 1); 
            if (!strstr($string, $char)){ 
                $string .= $char; 
            } 
        } 
        return $string; 
    } 
    if (count($inboxto) != 0){
        $count = 0;
        while ($count &lt; count($inboxto)){
            $recepient = $_POST['inboxto'][$count];

            mysql_query("INSERT INTO Inbox_tbl(InboxTo, InboxFrom, InboxSubject, InboxContent, InboxTime, InboxDate,InboxStatus,ToDelete,FromDelete)VALUES ('$recepient','$inboxfrom','$inboxsubject','$inboxcontent','$inboxtime','$inboxdate','Unread','No','No')");
            $recepient_result = mysql_query("SELECT * FROM Accounts_tbl WHERE UserID='$recepient'");
            if (mysql_result($recepient_result, 0, "UserTypeID") == 1){
                $notiurl = "LMSadmin_inbox.php";
            } else if (mysql_result($recepient_result, 0, "UserTypeID") == 2) {
                $notiurl = "LMSteacher_inbox.php";
            } else {
                $notiurl = "LMSstud_inbox.php";
            }
            mysql_query("INSERT INTO Noti_tbl(NotiTo,NotiFrom,NotiContent,NotiDate,NotiTime,NotiType,NotiUrl)
                VALUES('$recepient','$inboxfrom','has sent you a message','$inboxdate','$inboxtime','Message','$notiurl')");



//---------------------------------------------------------         
            $countto = 0;
            $cont = generateRandomString(128);
            $folder = "./Attachments/".$cont;
            $name = $_FILES['file']['name'];
            if (!empty($name)){
                    while (is_dir($folder)){
                        $cont = generateRandomString(128);
                        $folder = "./Attachments/".$cont;
                    }   
                    mkdir($folder, 0700, true);

            }
            while ($countto &lt; count($_FILES['file']['name'])){
                $name = $_FILES['file']['name'][$countto];
                $type = $_FILES['file']['type'][$countto];
                $tmp_name = $_FILES['file']['tmp_name'][$countto];
                $folder = "Attachments/".$cont."/";
                move_uploaded_file($tmp_name, $folder.$name);
                $fileurl = $cont."/".$name;
                $dummypost = mysql_query("SELECT * FROM Inbox_tbl ORDER BY InboxID DESC");
                $msgid = mysql_result($dummypost, 0, "InboxID");

                mysql_query("INSERT INTO Attachments_tbl(FileUrl,FileName,AttachType,AttachID)
                    VALUES('$fileurl','$name','Message',$msgid)");
                $countto++;
            }
//----------------------------------------------            


            $count++;   
        }
    }
    header('Location: ' . $_SERVER['HTTP_REFERER']);
?&gt;
</code></pre>

<p>now the result after I put multiple recepients and multiples is that... The first recepient will get the attachments.. meaning the folder of attachment will be randomy generated and the files would be put in there.... but on the next recepient the attachments would not be moved on their respective folder.. I can see the folder have been made but the files arent moved..</p>

<p>MY question is.. does the "temp_name" disappear after you use the "move_uploaded_file" code? Because I think thats is the reason the files arent not move.. Is so can you suggest any alternate code i can use?</p>
