Changed function generating names for uploaded files to the server.

This commit is contained in:
krzysiej
2022-06-09 11:09:51 +02:00
parent ccef18a2ca
commit 61ab01f297
2 changed files with 7 additions and 5 deletions

View File

@@ -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">{{

View File

@@ -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()
);
} }
/** /**