Thứ Tư, 25 tháng 12, 2013

Uploads nhiều file cùng một lúc && điều chú ý

 ************** phần code
 
<form id="form" method="post" action="post.php" enctype="multipart/form-data">
    <input type="file" name="userfile1"/>
    <input type="file" name="userfile2"/>
    <input type="file" name="userfile3"/>  
    <input type="submit" value="Upload" />
</form>

************** phần show ra

$shoppath="uploads/shop/pic/";    
    $images[] = @uploadimg_many("", "", 1, 400, $shoppath,"userfile1");
    $images[] = @uploadimg_many("", "", 1, 400, $shoppath,"userfile2");
    $images[] = @uploadimg_many("", "", 1, 400, $shoppath,"userfile3");


************** phần truyền vào

function uploadimg_many($images, $delpic, $thumb, $thumb_width, $upath,$name_input="userfile"){
     
####  uploads một file duy nhất
        if (is_uploaded_file($_FILES['userfile']['tmp_name']))
 ####  uploads nhiều file
          if (is_uploaded_file($_FILES[$name_input]['tmp_name']))
}

***************** chú ý
$datakod = date(U).rand(1,100);
--- nên cho rand() để không trùng thời gian

link website : zaracos


Không có nhận xét nào:

Đăng nhận xét