好的,所以我有一个具有多个文件输入的表单。当我提交表单时,文件没有上传。谁能帮忙。先感谢您。如果您需要更多信息,请告诉我...
HTML:
<input type="file" multiple="mulitple" id="image_file[]" name="image_file[]" />
PHP:
if (isset($_POST['submit'])) {
$target_path = ABSPATH . 'wp-content/uploads/portfolio-images/';
$target_file = $target_path . basename( $_FILES['image_file']['name']);
foreach ($_FILES['image_file']['error'] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES['image_file']['tmp_name'][$key];
$name = $_FILES['image_file']['name'][$key];
if (move_uploaded_file($tmp_name, $target_path)){
echo 'uploaded';
}
else {
echo 'failed';
}
}
}
}