1
그래서이 업로드 파일, 데이터베이스에 이미지를 업로드. 나는 오랫동안 Mysqli와 일하지 않았다. 그래서 내가 뭔가 잘못하고 있는지 모른다.이미지 실 거예요 mysqli 업로드
데이터베이스 테이블 (표지) : id (int 11), username (varchar 400), image (longblob).
<form action="insertimg.php" method="post" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" name="submit" id="submit" value="Submit Picture" />
</form>
이
는 업로드 파일입니다$name = $_SESSION['Band_name'];
$imageData = file_get_contents($_FILES["image"]["tmp_name"]);
$imageType = $_FILES["image"]["type"];
if(substr($imageType,0,5) == "image"){
$query = "INSERT INTO cover VALUES ('', '$name', '$imageData')";
$db->query($query) or die('Error, query failed');
}
오류가 있습니까? – apokryfos
코드를 실행하면 어떻게됩니까? –
후자는 내용을 문자열이 아닌 이진 데이터로 취급하기 때문에'file()'을 사용하지 않고'file_get_contents()'를 사용하지 않으려합니다. –