Zrobilem cos takiego:
<?
$userId = $_COOKIE['aausr'];
$data = db_get("SELECT * FROM search.file_processes WHERE user_id = $userId ORDER by id DESC");
?>
<div id="processes" class="processes" style="position: absolute; top: 320px; right: 0; float:right; max-width: 270px; color: #5f5f5f; padding: 10px; text-align: left; border: 1px solid #cacaca; border-shadow: 0 2px 4px rgba(0, 0, 0, 0.15)">
<table class='table'>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Status</th>
<th>Utworzono</th>
</tr>
</thead>
<tbody>
<?
foreach($data as $index => $value):
$status = ($value['status'] == 1)? 'Gotowe do pobrania.' : 'Trwa pobieranie' ;
?><tr data-id="
<? echo $value['id']; ?>"><td>
<? echo $value['id']; ?></td><td><a href="
<? echo '/uploads/'.$value['file_name']; ?>" download>
<? echo $value['file_name']; ?></a></td><td>
<? echo $status; ?></td><td>
<? echo date('Y-m-d H:i:s', $value['created_at']); ?></td><tr>
<?
endforeach;
?>
</tbody>
</table>
</div>
<link href='//cdn.datatables.net/1.10.7/css/jquery.dataTables.css' type='text/css' rel='stylesheet'/>
<script src='//cdn.datatables.net/1.3.0/js/jquery.dataTables.min.js' type='text/javascript'></script>
<script>
$(document).ready(function () {
$('.table').dataTable({
"sPaginationType": "full_numbers"
});
});
</script>
var processId = 0;
$(document).ready(function () {
$('.xls').click(function (e) {
e.preventDefault();
processId++;
var url = $(this).attr('data-href');
$.ajax({
method: "GET",
url: '?ajax=8',
dataType: "JSON",
data: {
processId: processId
},
beforeSend: function () {
$('.table tbody').prepend('<tr class="inprocess" data-id=' + processId + ' daata-inprocess="true"><td></td><td></td><td>Tworzenie pliku...</td><td></td></tr>');
},
success: function (res) {
var res = JSON.parse(res);
$
('.table tbody tr').find
('[data-id=' + res
.processId
+ ']').prevObject
[res
.processId
- 1].outerHTML
= '<tr data-id=' + res
.id
+ '><td>' + res
.id
+ '</td><td><a href=' + res
.file_url
+ '>' + res
.file_name
+ '</a></td><td>Gotowe do pobrania.</td><td>' + res
.time + '</td></tr>'; }
});
});
});
<?php
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel5.php';
function response() {
$data = db_get("SELECT * FROM `search`.file_processes");
$userId = $_COOKIE['aausr'];
$file_name = uniqid() . '.xls'; $sql = 'INSERT INTO search.file_processes (file_url, file_path, status, file_name,user_id, created_at) VALUES ("' . (PAA_ROOT_DIR . "uploads/$file_name") . '", "' . (PAA_ROOT_DIR . "uploads/$file_name") . '", "' . (0) . '", "' . $file_name . '","' . $userId . '", "' . $time . '")';
if (!db_query($sql)) {
}
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$row = 1;
for ($index = 0; $index < 10000; $index++) {
$objPHPExcel->getActiveSheet()->setCellValue('A' . $row, rand(0
, 7000000
)); $objPHPExcel->getActiveSheet()->setCellValue('B' . $row, rand(0
, 7000000
)); $objPHPExcel->getActiveSheet()->setCellValue('C' . $row, rand(0
, 7000000
)); $row++;
}
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->save(PAA_ROOT_DIR . "uploads/$file_name");
if (file_exists(PAA_ROOT_DIR
. "uploads/$file_name") == TRUE) { $sql = 'UPDATE search.file_processes SET status = 1 WHERE id = ' . $lastId;
db_query($sql);
echo json_encode
(array('processId' => $_GET['processId'], 'id' => $lastId, 'file_name' => $file_name, 'file_url' => ("/uploads/$file_name"), 'time' => date('Y-m-d H:i:s', $time))); }
}
response();
Ale ten kod i tak powoduje ze nie mozna nic zrobic podczas sciagania pliku jakies pomysly co moze byc?