반응형
내 데이터베이스에 삽입 할 이미지 파일을 가져 오는 데 문제가 있습니다. 다음과 같이 업로드 한 사진과 같은 사진 :
insert into('pic1.jpg');
insert into('pic2.jpg');
insert into('pic3.jpg');
이건 아니야:
insert into(Array[0] => pic1.jpg, Array[1] => pic2.jpg, Array[2] => pic3.jpg);
그래서 나는 그들의 이름 만 얻을 수 있고 내 데이터베이스에 삽입 할 수 있습니다. 메신저는 foreach 루프 를 사용해야합니다.
if(isset($_POST['upload'])){
$upload[] = ($_FILES['images']['name']);
print_r($upload);
}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<form method="POST" enctype="multipart/form-data">
<input type="file" name="images[]" multiple="multiple">
<input type="submit" name="upload" value="upload">
</form>
</body>
</html>
해결 방법
이 시도 ...
foreach ($_FILES['image']['tmp_name'] as $key => $val ) {
$filename = $_FILES['image']['name'][$key];
$filesize = $_FILES['image']['size'][$key];
$filetempname = $_FILES['image']['tmp_name'][$key];
$fileext = pathinfo($fileName, PATHINFO_EXTENSION);
$fileext = strtolower($fileext);
// here your insert query
}
참조 페이지 https://stackoverflow.com/questions/21423369
반응형
'MySql' 카테고리의 다른 글
MySQL PDO로 연결 제한 시간 설정 (0) | 2020.12.12 |
---|---|
MySQL INSERT INTO table IF 테이블이 존재하지 않으면 CREATE TABLE (0) | 2020.12.12 |
MySQL PHPExcel 다운로드가 제대로 작동하지 않음 (0) | 2020.12.12 |
MySQL 오류 파일 (0) | 2020.12.12 |
MySQL Rails Console은 ID 배열로 사용자를 찾습니다. (0) | 2020.12.12 |
댓글