mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-20 09:09:33 +00:00
Fixed upload error
This commit is contained in:
parent
3de9af8423
commit
43613a63a3
3 changed files with 14 additions and 5 deletions
|
|
@ -609,12 +609,17 @@ abstract class Attachment extends AbstractNamedDBElement
|
||||||
/**
|
/**
|
||||||
* Checks if the given path is a path to a builtin resource.
|
* Checks if the given path is a path to a builtin resource.
|
||||||
*
|
*
|
||||||
* @param string $path The path that should be checked
|
* @param string|null $path The path that should be checked
|
||||||
*
|
*
|
||||||
* @return bool true if the path is pointing to a builtin resource
|
* @return bool true if the path is pointing to a builtin resource
|
||||||
*/
|
*/
|
||||||
public static function checkIfBuiltin(string $path): bool
|
public static function checkIfBuiltin(?string $path): bool
|
||||||
{
|
{
|
||||||
|
//An empty path can't be a builtin
|
||||||
|
if ($path === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//After the %PLACEHOLDER% comes a slash, so we can check if we have a placeholder via explode
|
//After the %PLACEHOLDER% comes a slash, so we can check if we have a placeholder via explode
|
||||||
$tmp = explode('/', $path);
|
$tmp = explode('/', $path);
|
||||||
//Builtins must have a %PLACEHOLDER% construction
|
//Builtins must have a %PLACEHOLDER% construction
|
||||||
|
|
|
||||||
|
|
@ -115,12 +115,16 @@ class AttachmentPathResolver
|
||||||
* Converts an relative placeholder filepath (with %MEDIA% or older %BASE%) to an absolute filepath on disk.
|
* Converts an relative placeholder filepath (with %MEDIA% or older %BASE%) to an absolute filepath on disk.
|
||||||
* The directory separator is always /. Relative pathes are not realy possible (.. is striped).
|
* The directory separator is always /. Relative pathes are not realy possible (.. is striped).
|
||||||
*
|
*
|
||||||
* @param string $placeholder_path the filepath with placeholder for which the real path should be determined
|
* @param string|null $placeholder_path the filepath with placeholder for which the real path should be determined
|
||||||
*
|
*
|
||||||
* @return string|null The absolute real path of the file, or null if the placeholder path is invalid
|
* @return string|null The absolute real path of the file, or null if the placeholder path is invalid
|
||||||
*/
|
*/
|
||||||
public function placeholderToRealPath(string $placeholder_path): ?string
|
public function placeholderToRealPath(?string $placeholder_path): ?string
|
||||||
{
|
{
|
||||||
|
if (null === $placeholder_path) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
//The new attachments use %MEDIA% as placeholders, which is the directory set in media_directory
|
//The new attachments use %MEDIA% as placeholders, which is the directory set in media_directory
|
||||||
//Older path entries are given via %BASE% which was the project root
|
//Older path entries are given via %BASE% which was the project root
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@
|
||||||
<img class="img-fluid img-thumbnail thumbnail-sm" src="{{ attachment_thumbnail(attach, 'thumbnail_md') }}" alt="{% trans %}attachment.preview.alt{% endtrans %}" />
|
<img class="img-fluid img-thumbnail thumbnail-sm" src="{{ attachment_thumbnail(attach, 'thumbnail_md') }}" alt="{% trans %}attachment.preview.alt{% endtrans %}" />
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ entity_url(attach, 'file_view') }}" rel="noopener" target="_blank" data-turbo="false" class="link-external">{% trans %}attachment.view{% endtrans %}</a>
|
<a href="{{ entity_url(attach, 'file_view') }}" rel="noopener" target="_blank" data-turbo="false" class="link-external">{% trans %}attachment.view_local{% endtrans %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue