按顺序上传文件

时间:2012-11-25 16:54:52

标签: php javascript file-upload

我想按顺序上传文件。当我这样做时,我上传的文件将进入文件系统,而我的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;
}

0 个答案:

没有答案