Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download and view file on Edit page #14

Open
vayurobins opened this issue Jan 7, 2020 · 3 comments
Open

Download and view file on Edit page #14

vayurobins opened this issue Jan 7, 2020 · 3 comments

Comments

@vayurobins
Copy link

Hi.
Is it possible to have a download link to the uploaded file after it has been saved to the database/S3?

@milewski
Copy link
Member

Hi perhaps this is supported by installing this plugin: https://github.com/nielsboogaard/filepond-plugin-get-file, can you have a try if it works I can incorporate into this field

@royduin
Copy link

royduin commented Feb 12, 2020

Another approach could be to only show this field on forms with ->onlyOnForms() and then create a "fake" text field where you can do whatever you want, for example:

Text::make('Attachments', function () {
    $html = '';
    foreach ($this->attachments ?? [] as $attachment) {
        $html .= '<li><a href="'.$attachment.'">'.$attachment.'</a></li>';
    }
    return $html ? '<ul>'.$html.'</ul>' : null;
})->asHtml()->onlyOnDetail(),

@Shehan-Sara
Copy link

Shehan-Sara commented Jul 18, 2024

@royduin I modified your code a bit. Hopefully, this works for me.

Text::make('documents', function () {
                $appUrl = Config::get('app.url'); // Fetch the APP_URL from the configuration
                $html = '';
                foreach ($this->documents ?? [] as $document) {
                    $html .= '<li><a href="' . $appUrl . '/storage/' . $document . '" target="_blank">' . $appUrl . '/storage/' . $document . '</a></li>';
                }
                return $html ? '<ul>' . $html . '</ul>' : null;
            })->asHtml()->onlyOnDetail(),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants