uploadify を使用し、その multi パラメータを true に設定します
<input type="file" name="file_upload" id="file_upload" />
$(function() {
$("#file_upload").uploadify({
'multi' : true,
'swf' : '/uploadify/uploadify.swf',
'uploader' : '/uploadify/uploadify.php' ,
'onUploadSuccess' : function(file, data, response) {
// Use the 'file' object to get the filename and stuff and put it somewhere on the page.
}
});
});
サーバ側:
$targetFolder = '/uploads'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo $targetFolder . '/' . $_FILES['Filedata']['name'];
} else {
echo 'Invalid file type.';
}
}