PHP로 프로젝트를 만들고 있는데 로컬 데이터베이스에 파일을 업로드 할 수 있으며 파일 정보를 검색 할 수 있습니다. 파일 자체를 가져 와서 내 컴퓨터로 다운로드하는 방법을 모르겠습니다. 누군가 도와 주실 수 있습니까? 데이터베이스에 - 열/유형 = ID-INT, 이름 VARCHAR, 마임 LONGBLOB, 크기 biginet, 데이터 MEDIUMBLOB, 파일 정보를 검색하기위한 생성 - 날짜업로드 된 파일을 다운로드하는 방법?
빌을 :
header('Content-Type: text/html; charset=utf-8');
$connection = mysqli_connect('localhost', 'root', '', 'hamatkin');
mysqli_query($connection, "SET character_set_client = utf8");
mysqli_query($connection, "SET character_set_connection = utf8");
mysqli_query($connection, "SET character_set_results = utf8");
if (!$connection) {
die("couldnt connect".mysqli_error);
}
$query = "SELECT id, name, created FROM file";
$queryResult = $connection->query($query);
$queryResult2 = array();
if ($queryResult === false) {
die($connection->error);
}
if ($queryResult->num_rows > 0) {
while ($row = $queryResult->fetch_assoc()) {
$queryResult2[] = $row;
}
}
$queryResult3 = json_encode($queryResult2);
echo json_encode($queryResult2);
컨트롤러 :
"use strict";
angular.module('dataSystem').controller('allPriceOffersCtrl', function($scope,$route,$location,$http) {
$http({method:'GET', url:'api/customers-tab/get-all-priceOffers.php/'})
.then(function(response) {
var arr = response.data;
$scope.files = arr;
})
// This will log you the error code and trace, if there is an error.
.catch(function(err) {
console.log('err', err)
});
});
HTML :
<div class="table-responsive">
<table class="customer-list table table-striped">
<thead>
<tr>
<!-- <th>#</th> -->
<th class="Column-Header"> מספר קובץ הצעת מחיר</th>
<th class="Column-Header">שם הקובץ</th>
<th class="Column-Header">תאריך</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in files ">
<!-- <td>{{$index + 1}}</td> -->
<td>{{ x.id}}</td>
<td>{{ x.name}}</td>
<td> {{ x.created}} </td>
</tr>
</tbody>
</table>
</div>
데이터베이스에 파일을 BLOB 요소로 저장 하시겠습니까? –
@ GeeK 그게 좋지 않아? 이걸로 내가 처음인데 미안해 ... 너 뭐라고 제안 하나? – tanyaa
내 답변이 도움이되기를 바랍니다. 자세한 내용이 필요하면 알려주세요. –