Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.15k stars 891 forks source link

[Bug] field upload : the uploaded file link is not correct #5598

Open rezahmady opened 2 months ago

rezahmady commented 2 months ago

Bug report

What I did

my disk :

'stg1' =>  [
    'driver' => 'ftp',
    ...
    'url' => 'https://{my_domain}/uploads'
]

field :

[
    'name'  => 'url',
    'type' => 'upload',
    'withFiles' => [
        'disk' => 'stg1',
        'path' => 'videos',
    ],
    'fake'  => true,
]

What I expected to happen

download link must be :

https://{my_domain}/uploads/videos/{my_file}

What happened

When I set a disk other than public, the path value set in the upload field is used twice in the download link.

download link :

https://{my_domain}/uploads/videos/videos/{my_file}

What I've already tried to fix it

image

this is your code what id prefix ??

I set prefix value to '' or '/' but it didn't work

[
    'name'  => 'url',
    'type' => 'upload',
    'prefix' => '',
    'withFiles' => [
        'disk' => 'stg1',
        'path' => 'videos',
        'prefix' => '',
    ],
    'fake'  => true,
]

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there?

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### PHP VERSION:
8.3.6

### PHP EXTENSIONS:
Core, bcmath, calendar, ctype, date, filter, hash, iconv, json, SPL, pcre, random, readline, Reflection, session, standard, mysqlnd, tokenizer, zlib, libxml, dom, PDO, openssl, SimpleXML, xml, xmlreader, xmlwriter, curl, ftp, fileinfo, gd, intl, mbstring, exif, mysqli, Phar, pdo_mysql, xsl, zip

### LARAVEL VERSION:
10.48.15.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.4
backpack/crud: 6.7.24
backpack/editable-columns: 3.0.9
backpack/filemanager: 3.0.8
backpack/generators: v4.0.5
backpack/logmanager: v5.0.2
backpack/pro: 2.2.4
backpack/revise-operation: 2.0.0
backpack/theme-coreuiv2: 1.2.4
jcastroa87 commented 2 months ago

Hello @rezahmady

I try this today with this version:

### PHP VERSION:
8.3.10

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dba, dom, hash, FFI, fileinfo, filter, ftp, gd, gettext, gmp, json, iconv, intl, SPL, ldap, mbstring, session, standard, odbc, pcntl, exif, mysqlnd, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, random, readline, Reflection, mysqli, shmop, SimpleXML, soap, sockets, sodium, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, xml, xmlreader, xmlwriter, xsl, zip, Zend OPcache

### LARAVEL VERSION:
11.21.0.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.6
backpack/crud: 6.7.33
backpack/devtools: 3.1.6
backpack/generators: v4.0.5
backpack/pro: 2.2.14
backpack/theme-coreuiv2: 1.2.5
backpack/theme-tabler: 1.2.12

Filesystem

'stg1' =>  [
            'driver' => 'ftp',
            'host' => 'test.rebex.net',
            'username' => 'demo',
            'password' => 'password',
            'url' => 'https://bp.test/uploads'
        ],

Controller

CRUD::field([
            'name'  => 'upload',
            'label' => 'Photos',
            'type'  => 'upload',
            'withFiles' => [
                'disk' => 'stg1',
                'path' => 'videos',
            ],
            'fake'  => true,
        ]);

And i get the url

https://domain.test/uploads/videos/File.txt

As i understand this is working normal now.

Let me know if work for you.

Cheers.