Changed function generating names for uploaded files to the server.
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Id</th>
|
|
||||||
<th>File name</th>
|
<th>File name</th>
|
||||||
<th class="text-end">File size</th>
|
<th class="text-end">File size</th>
|
||||||
<th>Extension</th>
|
<th>Extension</th>
|
||||||
@@ -16,7 +15,6 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="file in files">
|
<tr v-for="file in files">
|
||||||
<td>{{ file.id }}</td>
|
|
||||||
<td>{{ file.fileName }}
|
<td>{{ file.fileName }}
|
||||||
<p class="mb-0" v-if="file.book">
|
<p class="mb-0" v-if="file.book">
|
||||||
<a class="text-decoration-none" :href="'/book/'+file.book.id">{{
|
<a class="text-decoration-none" :href="'/book/'+file.book.id">{{
|
||||||
|
|||||||
@@ -45,9 +45,13 @@ class FileService
|
|||||||
|
|
||||||
public function getFileName(File $file): string
|
public function getFileName(File $file): string
|
||||||
{
|
{
|
||||||
return 'ebook_' . $file->getBook()->getId() . '_' .
|
return sprintf(
|
||||||
md5($file->getFileName()) . '.' .
|
'ebook_%d_%d_%s.%s',
|
||||||
$file->getExtension();
|
$file->getBook()->getId(),
|
||||||
|
$file->getId(),
|
||||||
|
md5($file->getFileName()),
|
||||||
|
$file->getExtension()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user