1
我已經有一個上傳多個文件(HTML,JS,PHP)的系統。在HTML5中拖放多個文件?
現在,我有一個輸入倍數。但是我想用Drag & Drop without change系統PHP使用$_FILES["uploadfile"]
可能嗎?
HTML
<input type="file" name="uploadfile[]" multiple="" style="position: absolute; margin: -5px 0px 0px -175px; padding: 0px; width: 220px; height: 30px; font-size: 14px; opacity: 0; cursor: pointer; display: none; z-index: 2147483583; top: 83px; left: 333px;">
<div id="dropzone" style="border: 3px solid #DDD; width: 400px; height: 400px;"></div>
PHP
$uploaddir = 'uploads/';
$files = array();
foreach ($_FILES["uploadfile"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$path = $uploaddir . basename($_FILES['uploadfile']['name'][$key]);
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'][$key], $path)) {
$files [] = array (
'title' => $_FILES['uploadfile']['name'][$key],
'url' => $path,
'size' => $_FILES['uploadfile']['size'][$key]
);
}
}
}
echo json_encode($files);