我想上传两张图片,一张是用户的,另一张是他的ID,使用mysqli的提交按钮。这是我的HTML。
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
your image: <input type="file" name="img"><br/>
your Id card: <input type="file" name="img2">
<input type="submit" name="publish" value="upload">
</form>
</body>
</html>
所有我知道的是上传单个图像一次,但如果要上传这些图像到数据库中的单次提交怎么办。我不是在写PHP,因为我不知道怎么做。我可以使用一个数组一次上传多个图像,但我想使用这种方法。用PHP可以吗??
PHP支持单次上传:
<?php
$dir = "uploads/";
$t_file = $dir . basename($_FILES["img"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($t_file,PATHINFO_EXTENSION));
if(isset($_POST["upload"])) {
$check = getimagesize($_FILES["img"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
?>
https://stackoverflow.com/questions/50630428
复制相似问题