ADD начало импорта сразу после аплоада файла; возможность скачать исходный файл
This commit is contained in:
parent
cd963f2be2
commit
0dc2ce90ec
|
|
@ -60,7 +60,30 @@ class TracksController extends Controller
|
|||
App::error404();
|
||||
}
|
||||
|
||||
App::redirect('/tracks/files');
|
||||
App::redirect('/tracks/importgpx/id/'.$tmp->id);
|
||||
}
|
||||
|
||||
function actionGetFile()
|
||||
{
|
||||
$id = intval(App::getParam('id'));
|
||||
|
||||
if (!$id) {
|
||||
App::error404();
|
||||
}
|
||||
|
||||
$trackFile = TrackFiles::model()->getByPK($id);
|
||||
|
||||
if ($trackFile->isEmpty() || $trackFile->owner != App::$user->id) {
|
||||
App::error404();
|
||||
}
|
||||
|
||||
$temp = pathinfo($trackFile->filename);
|
||||
$extension = strtolower($temp['extension']);
|
||||
|
||||
self::renderPartial('file.php', array(
|
||||
'filePath' => App::getBasedir(). 'tracks/track' . $id . '.' . $extension,
|
||||
'fileName' => $trackFile->filename,
|
||||
));
|
||||
}
|
||||
|
||||
function actionImportgpx()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
if (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
if (!isset($fileName)) {
|
||||
$fileName = basename($filePath);
|
||||
}
|
||||
|
||||
header('Connection: close');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename=' . $fileName);
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Cache-Control: must-revalidate');
|
||||
// header('Transfer-Encoding: chunked');
|
||||
// Читаем файл и отправляем его пользователю
|
||||
readfile($filePath);
|
||||
}
|
||||
|
|
@ -1,17 +1,9 @@
|
|||
<form method="POST" action="/tracks/uploadfile/" enctype="multipart/form-data" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="uploadfile">Загрузить новый файл</label>
|
||||
<input type="file" name="file" id="uploadfile" class="form-control" accept=".gpx"/>
|
||||
<button type="submit" class="btn btn-success" title="Загрузить выбранный файл"><span class="glyphicon glyphicon-upload" aria-hidden="true"></span></button>
|
||||
</div>
|
||||
</form>
|
||||
<hr/>
|
||||
<h3>Ваши файлы с треками</h3>
|
||||
<?php
|
||||
|
||||
if ($files) {
|
||||
foreach ($files as $file) {
|
||||
print $file->id . ' — <span title="' . $file->filename . '">' . $file->name . ' [' . $file->tracksCount.' . ' . $file->tptCount.' . ' . $file->wptCount . '] <a href="/tracks/importgpx/id/' . $file->id . '" title="Импортировать - создать НОВЫЙ трек на карте"><span class="glyphicon glyphicon-import" aria-hidden="true"></span></a><br/>';
|
||||
print $file->id . ' — <span title="' . $file->filename . '">' . $file->name . ' [' . $file->tracksCount.' . ' . $file->tptCount.' . ' . $file->wptCount . '] <a href="/tracks/getfile/id/' . $file->id . '" title="Скачать файл"><span class="glyphicon glyphicon-download" aria-hidden="true"></span></a><br/>';
|
||||
}
|
||||
} else {
|
||||
print 'Пока ничего не загружено';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,21 @@
|
|||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td>
|
||||
<h3>Ваши треки</h3>
|
||||
<a href="/tracks/files">загрузка треков</a>
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<form method="POST" action="/tracks/uploadfile/" enctype="multipart/form-data" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="uploadfile">Загрузить новый файл</label>
|
||||
<input type="file" name="file" id="uploadfile" class="form-control" accept=".gpx"/>
|
||||
<button type="submit" class="btn btn-success" title="Загрузить выбранный файл"><span class="glyphicon glyphicon-upload" aria-hidden="true"></span></button>
|
||||
|
||||
<a href="/tracks/files" class="btn btn-default" title="Раздел с файлами треков"><span class="glyphicon glyphicon-download" aria-hidden="true"></span></a>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr/>
|
||||
<?php
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue