-3
아래 코드 (imageupload.php)를 사용하여 파일을 서버에 업로드하고 데이터베이스에 데이터를 삽입하는 위치에 있습니다.이 코드와 관련된 html 폼을 만드는 방법
<?php
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
die();
}
$result = 0;
//UPLOAD IMAGE FILE
move_uploaded_file($_FILES["fileImage"]["tmp_name"], "ImageFiles/" . $_FILES["fileImage"]["name"]);
$result = 1;
//INSERT INTO IMAGE DATABASE TABLE
$imagesql = "INSERT INTO Image (ImageFile) VALUES (?)";
if (!$insert = $mysqli->prepare($imagesql)) {
// Handle errors with prepare operation here
}
//Dont pass data directly to bind_param store it in a variable
$insert->bind_param("s", $img);
//Assign the variable
$img = 'ImageFiles/' . $_FILES['fileImage']['name'];
$insert->execute();
$insertimagequestion->execute();
//IF ANY ERROR WHILE INSERTING DATA INTO EITHER OF THE TABLES
if ($insert->errno) {
// Handle query error here
}
$insert->close();
}
?>
하지만이 형식과 연결할 html 양식을 만들고 싶지만 html로 파일 입력을 생성하지 않았습니다. 아무도이와 관련된 수있는 HTML 양식을 만드는 방법을 알고 있습니까?
위 코드를 테스트하여 오류가 있는지 테스트 할 수 있도록 html 코드가 필요합니다. 당신은 다음과 같이 HTML 양식을 만들 수 있습니다
당신은 찾을 수이 도움이 : http://php.net/manual/en/features.file-upload.post-method.php – andrewsi