0

我想按顺序上传文件。当我这样做时,我最后上传的文件将进入文件系统,而我的 php 代码将看不到我之前上传的文件。有人有类似的问题吗?

function inputImages() 
{
    print_r($_FILES);
    $images_number = count($_FILES['images']['name']);
    $uploadDir = 'tmp_name/';
    $images = array();

    for ($i=0; $i<$images_number; $i++) {
        $fileName = $_FILES['images']['name'][$i];
        $tmpName  = $_FILES['images']['tmp_name'][$i];
        $permanentname = sha1($tmpName.$fileName.rand()).substr($fileName,-4);
        $filePath = $uploadDir . $permanentname;
        $result = move_uploaded_file($tmpName, $filePath);  
        if (!$result) {
         $ErrorMessage.= "Error uploading <strong>file</strong>";
        } else {
            array_push($images, $permanentname);            
        }        
    }
    return $images;
}
4

0 回答 0