Lessons I : Đoạn code để Upload nhieu file trong PHP

Đoạn code để Upload nhieu file trong PHP


Xin giới thiệu với các bạn đoạn Code để Upload nhieu file trong PHP:

PHP Code:

<?php
$numoffile = 5;
$file_dir = ”/ subdomain/files/”; // Tên đường dẫn thư mục chứa file upload
if ($_POST) {
for ($i=0;$i<$numoffile;$i++) {
if (trim($_FILES[‘myfiles’][‘name’][$i])!=””) {
$newfile = $file_dir.$_FILES[‘myfiles’][‘name’][$i];
move_uploaded_file($_FILES[‘myfiles’][‘tmp_name’][$i], $newfile);
$j++;
}
}
}
if (isset($j)&&$j>0) print ”Tập tin đã được upload.<br>”;
print ”<form method=’post’ enctype=’multipart/form-data’>”;
for($i=0;$i<$numoffile;$i++) {
print ”<input type=’file’ name=’myfiles[]’ size=’30’><br>”;
}
print ”<input type=’submit’ name=’action’ value=’Upload’>”;
print ”</form>”;
?>

 

Nguồn : PHP manual

Posted by vns3curity(HCE)

 

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: