简体   繁体   中英

How to preview image file after it is selected, and before uploading on Laravel Nova 4

I would like to know how to preview the image after it is selected, and before submitting the form on Laravel Nova 4?

# App/Nova/Image.php

/**
 * Get the fields displayed by the resource.
 *
 * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
 * @return array
 */
public function fields(NovaRequest $request)
{
    return [
        ID::make()->sortable(),
        Image::make('image')->disk('s3')->path('s3-uploads/event_images')->acceptedTypes('image/*'),                      
    ];
}

Is it possible to execute custom javascript on a Laravel Nova Form that detects when the image file is selected and inserts a preview in the form? Or is there a simpler / recommended way to do it?

Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM