Git Product home page Git Product logo

laravel-filepond's People

Contributors

rahulhaque avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-filepond's Issues

Uploading large files and using `moveTo()` can produce out of memory exceptions

Hey,

we've been using this package to manage uploads of rather large files (movies, up to 10GB) and have repeatedly run into out-of-memory exceptions. I think I've been able to track it down to the moveTo() function, which calls putFile() which runs:

Storage::disk($permanentDisk)->put($path.'.'.$filepond->extension, Storage::disk($this->getTempDisk())->get($filepond->filepath), $visibility);

I think replacing the Filesystem::get() to read the contents of the file with Filesystem::readStream() could fix this issue.

How to use this with `vue-filepond`?

Hello, I tried to use your dependency, but seems not working and $fileInfos is just empty array. What does Filepond::field($request->gallery) does expect from $request->gallery? Because I need to know since vue-filepond didn't store anything on my gallery data object, so I manually inject the serverId when submitting the form like this

this.$refs.pond.getFiles().forEach((el) => {
      this.form.gallery.push(el.serverId);
});

Kindly need your help. Thank you !

Required validation is not working

Hi, required validation rule is not working. If I submit the form without any file uploaded it does not show any validation error and the server get crashed.
Here is my controller to store image

 public function storeImage(Request $request) {
        $formFields = $request->validate([
            'altText' => ['max:50'],
            'caption' => ['max:200'],
            'image' => Rule::filepond([
                'required',
                'file',
                'mimes:jpg,jpeg,png,webp,gif',
            ]),
        ]);


        // Set filename
        $imageName = 'media-img-' . Str::uuid()->toString();

        // Move the file to permanent storage
        // Automatic file extension set
        $imageInfo = Filepond::field($request->image)
            ->moveTo('media/image/' . $imageName);

        // Save to DB
        RecentUpdate::create([
            'file_path' => $imageInfo['location'],
            'file_type' => 'image',
            'file_ext' => $imageInfo['extension'],
            'alt_text' => $formFields['altText'],
            'caption' => $formFields['caption'],
        ]);

        // Redirect
        return redirect()
            ->route('admin.recent-updates.index')
            ->with('message', 'Post created successfully');
    }

The error message says Trying to access array offset on value of type null and it is because I am accessing 'file_path' => $imageInfo['location'] and $imageInfo is null.

is there anything I missed ?

Does not work on AWS S3/wasabi

If I use localhost as file storage, It works. On the other hand, I'm getting error when I use the moveTo() function in S3/wasabi storage.

image

The payload is invalid

I did a basic configuration of filepond.
Client side:

FilePond.setOptions({
        credits: false,
        allowMultiple: true,
        server: {
            url: 'url',
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
            }
        }
    });

FilePond.create(document.querySelector('input[name="nuovo_file"]'));

Server side:
$fileInfo = Filepond::field('nuovo_file')->getFile();

I have this error:
The payload is invalid. {"userId":1,"exception":"[object] (Illuminate\Contracts\Encryption\DecryptException(code: 0): The payload is invalid. at /vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:214

if I use this code on server side work fine:

$file=$request->file('nuovo_file');
$nomeFile=$file->getClientOriginalName();
........

Can some one help me?

Error grouping multiple filepond fields using array notation

Hi rahulhaque,

Thanks again for your work on this awesome project. I have an unusual scenario where I'm trying to group filepond upload files using array notation.

I'm experiencing Error 500 response when I try to upload a file to the second field.

I'm using version: 1.12.13.

Here is a sample of what I'm trying to achieve. You'll notice I'm using name="assets[pptx]" and name="assets[pdf]"

<label for="pptx" class="wsm-label">PowerPoint</label>
<input id="pptx" class="filepond" type="file" name="assets[pptx]" required data-label-idle="Drop or select a PowerPoint file (.pptx)" data-accepted-file-types="application/vnd.openxmlformats-officedocument.presentationml.presentation" />
<p class="help-block">{{ $errors->first('assets[pptx]') }}</p>
                                        
<label for="pdf" class="wsm-label">PDF</label>
<input id="pdf" class="filepond" type="file" name="assets[pdf]" required data-label-idle="Drop or select a PDF file (.pdf)" data-accepted-file-types="application/pdf" />
<p class="help-block">{{ $errors->first('assets[pdf]') }}</p>

My JS config is as follows:

// Register plugins
FilePond.registerPlugin(FilePondPluginFileValidateSize);
FilePond.registerPlugin(FilePondPluginFileValidateType);

// Set default FilePond options
FilePond.setOptions({
  // Enabled chunked uploads
  chunkUploads: true,
  server: {
    url: "{{ config('filepond.server.url') }}",
    headers: {
      'X-CSRF-TOKEN': "{{ @csrf_token() }}",
    }
  }
});

FilePond.parse(document.body);

Is array notation supported? If so, any support, suggestions and/or insights you can provide about why I'm receiving Error 500 would be much appreciated. If the fields are named uniquely without array notation: name="assets_pptx" name="assets_pdf", I do not experience this issue and everything works perfectly.

delete temp file on validation fail

Hi, is there a way to automatically delete the temp stored file if any of the other fields of the form fail validation ?
I understand there is the expiration setting and a cron can be set, but it puts friction to the process

Thanks

Error when using onprocessfile - not valid JSON returned.

Hello! When files uploaded response contains some long string, not JSON, i have added filepond* to except array, tried to disable debugbar, but nothing changed..
In dev console:
caught SyntaxError: Unexpected token 'e', "eyJpdiI6In"... is not valid JSON

request to filepond during upload returns string:
eyJpdiI6InQ1b3hTb2RBVVZGNWdybDRIeC9icGc9PSIsInZhbHVlIjoib1d5RVRNRDFnVzRLNzE2RzRwVklMbGs5eUFnUC96YWJoc2ZxaDRBR0QrVT0iLCJtYWMiOiIyMjAzZTA2NjU5OWMwMjdjMTQzZmRiMzY2ZTBiYWRlMmM1NDRjMzFiNTc3NGQxMGNmMWVhMWE5M2MzYTgxZDgzIiwidGFnIjoiIn0=

edit: Looks like return string is always the same, no matter what file i upload.

Project: Laravel 10 + Livewire, php 8.1

Help me please :(

getFile() function

I'm trying to use the getFile() function according to the documentation "$fileInfo = Filepond::field($request->file)->getFile()", but the response is an empty array. Need help

Multiple Uploads Saved as Single Item

Hello,

Thank you for your work on this package, it is exactly what I need to make the connection between Filepond, Inertia and Laravel.

I'm attempting to upload multiple images and it looks that is successful at least for the temporary files. However, when I go to the storage path, I only see one image, instead of 'x' amount of images. I'm not sure if I'm missing a step or the functionality is actually broken.

Filepond Instance:

<file-pond
                                name="image[]"
                                ref="pond"
                                credits=""
                                allowMultiple="true"
                                maxFiles="5"
                                label-idle="Click to choose image, or drag here..."
                                accepted-file-types="image/jpg, image/jpeg, image/png"
                                max-file-size="3MB"
                                @processfile="handleFilePondProcess"
                                @removefile="handleFilePondRemoveFile"
                            />

Vue data array:

data() {
        return {
            products: this.products,
            stores: this.stores,
            brands: this.brands,
            form: this.$inertia.form({
                _method: "post",
                product: "",
                brand: "",
                store: "",
                tags: "",
                image: [],
                title: "",
                link: "",
                discount: "",
                price: "",
                price_extras: "",
                description: ""
            })
        };
    },

Vue methods:

 handleFilePondProcess: function(error, file) {
            // Set the server id from response
            this.form.image = file.serverId;
        },
        handleFilePondRemoveFile: function(error, file) {
            // Remove the server id on file remove
            this.form.image = null;
        }

Controller:

 Filepond::field($request->image)->moveTo('deals/deal-' . $deal->id);

resize images before uploading

Hello ,
have a nice day,
first of all thank you so much for this amazing package , it helps me a lot.
second thing I am wondering if is there any a proper way that I can use to resize images before uploading them by using this package.

Thanks in advance.

Error in laravel 8 jetstream

I got this error

Illuminate\Contracts\Encryption\DecryptException: The payload is invalid. in file D:\Software Projects\atc\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php on line 223

#0 D:\Software Projects\atc\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php(158): Illuminate\Encryption\Encrypter->getJsonPayload()
#1 D:\Software Projects\atc\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(261): Illuminate\Encryption\Encrypter->decrypt()
#2 D:\Software Projects\atc\vendor\rahulhaque\laravel-filepond\src\AbstractFilepond.php(153): Illuminate\Support\Facades\Facade::__callStatic()
#3 D:\Software Projects\atc\vendor\rahulhaque\laravel-filepond\src\AbstractFilepond.php(58): RahulHaque\Filepond\AbstractFilepond->decrypt()
#4 D:\Software Projects\atc\vendor\rahulhaque\laravel-filepond\src\Filepond.php(19): RahulHaque\Filepond\AbstractFilepond->setFieldValue()
#5 D:\Software Projects\atc\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(261): RahulHaque\Filepond\Filepond->field()

here is the snippet

Filepond::field($request->document)
            ->validate(['document' => 'required|file|image']);

Attempt to read property "disk" on null"

Dear Sir
When I'm trying to move and validate or any other methods after field() it throws null errors.

Filepond::field($request->input('logo_url'))->validate(['logo_url' => 'required|image|max:3000']);
        $fileName = \Str::random(20) . '_brand';
        $destination = 'uploads/brand/';
$fileInfo = Filepond::field($request->input('logo_url'))
        ->moveTo($destination . $fileName);

Any help will be appreciated.

Laravel 9?

How soon will you enable Laravel 9 support?

Problem 1
    - Root composer.json requires rahulhaque/laravel-filepond ^1.4 -> satisfiable by rahulhaque/laravel-filepond[v1.4.8].
    - rahulhaque/laravel-filepond v1.4.8 requires illuminate/support ^7.0|^8.0 -> found illuminate/support[v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.

How to access the data?

Screenshot_116
I using a spatie media, so i need a string of the image path. for now i just do like on the screenshot, and i believe this is incorrect ways.
thank for your response

Allow use of custom model

In some cases we need to use a custom model. In my case, I have a multi tentant app, So I need do save more data in the Filepond model.

I've created the PR #44, if you could accept this PR, I will be so greatfull

Attempt to read property "extension" on null

I randomly get the error, using always the same image for testing
I need the extension because I am changing the file name on store
Database record is stored correctly ...

Screenshot 2021-11-11 at 16 26 42

$logoType = Filepond::field($request->logo);
$logoType = $logoType->getModel()->extension;

Uncaught ReferenceError: FilePond is not defined

Followed the installation and I got this error..


 <script>
        // Set default FilePond options
        FilePond.setOptions({
            server: {
                process: "{{ config('filepond.server.process') }}",
                revert: "{{ config('filepond.server.revert') }}",
                headers: {
                    'X-CSRF-TOKEN': "{{ @csrf_token() }}",
                }
            }
        });
        FilePond.create(document.querySelector('input[type="file"]'));
    </script>

The file "..." does not exist

When using S3 as temp disk and permanent storage, I get the following error when storing the file:

The file "filepond/temp/YTXkkiSEtz6IEZNT4nKTNSvRHkX9nHIq4l4jbEYS.zip" does not exist

Is this a known issue? S3 being AWS here. When using this locally, eg. with a local storage, the error is not thrown.

Size not available

When I want to use FilePoster I get size unavailable. Is there something I missed with my codes as below?

`
FilePond.registerPlugin(
FilePondPluginFilePoster,
FilePondPluginImagePreview
);

FilePond.create(document.querySelector('input[name="cover"]'));
FilePond.setOptions({
    server: {
        url: "{{ config('filepond.server.url') }}",
        headers: {
            'X-CSRF-TOKEN': "{{ @csrf_token() }}",
        },
    },
    files: [
        {
            source: "http://127.0.0.1:8000/storage/covers/project-cover-639cf605b3251.png",
            options: {
                type: 'local',
                metadata: {
                    poster: "http://127.0.0.1:8000/storage/covers/project-cover-639cf605b3251.png",
                },
            }
        }
    ]
});

`

I am getting error Argument 1 passed to RahulHaque\Filepond\Services\FilepondService::offset() must be of the type string

How should I go about this?
Thanks

Delete fails with multiple upload

When uploading multiple files with filepond, and then calling
$filepond = Filepond::field($filepondToken)->delete();
The error is: Method Illuminate\Database\Eloquent\Collection::delete does not exist.

The reason is that at

if ($this->getIsMultipleUpload()) {
$fileponds = $this->getFieldModel();
foreach ($fileponds as $filepond) {
if ($this->getIsSoftDeletable()) {
$filepond->delete();
} else {
Storage::disk($filepond->disk)->delete($filepond->filepath);
$filepond->forceDelete();
}
}
}
$filepond = $this->getFieldModel();
if ($this->getIsSoftDeletable()) {
$filepond->delete();
} else {
Storage::disk($filepond->disk)->delete($filepond->filepath);
$filepond->forceDelete();
}

there is a missing else case, since $filepond = $this->getFieldModel(); returns a Collection, it tries calling ->delete() on a Collection instance.

Problema no getFile()

Estou utilizando a função getFile() para pegar as informações das fotos, mas não esta vindo as informações mesmo com dados na função Filepond::field(). Pode me ajudar nisso.
image

Remove file(s) after Upload.

Hello everyone,

I have encountered the following situation:

Situation

as soon as I upload file(s) and then delete a file (via Filepond UI) and then save my form, I get the following error:

RahulHaque\Filepond\AbstractFilepond::createFileObject(): Argument #1 ($filepond) must be of type RahulHaque\Filepond\Models\Filepond, null given, called in /home/vagrant/projects/***/vendor/rahulhaque/laravel-filepond/src/Filepond.php on line 43

My environment

Server side

  • Package Version: 10.0.0
  • PHP Version: 8.2.9
  • Laravel Version: 10.35.0

Possibly relevant: I use the Jetstream/Inertia/Vuejs stack.

The filepond.php settings that deviate from the default file:

'middleware' => [
    'web', 'auth', 'authorize_by_route',
],
'soft_delete' => true,

Middleware for store route:

    public function rules(): array
    {
        return [
            ...
            'attachments' => 'required|array',
            'attachments.*' => [
                'required',
                Rule::filepond([
                    'max:10240',
                    'mimes:jpeg,png,pdf',
                ]),
            ],
        ];
    }

NPM Packages

    "devDependencies": {
        "vite": "^4.0.0",
        "vue": "^3.3.6",
        ...
    },
    "dependencies": {
        "filepond": "^4.30.4",
        "filepond-plugin-file-validate-type": "^1.2.8",
        "filepond-plugin-image-preview": "^4.6.11",
        "vue-filepond": "^7.0.3",
        ...
    }

Frontend (Vuejs Component)

<FilePond
    name="attachment"
    ref="filepond"
    :label-idle="$t('layouts.appLayout.filepondLabelIdle')"
    accepted-file-types="image/jpeg, image/png, application/pdf"
    v-bind:files="form.attachments"
    v-bind:allow-multiple="true"
    v-on:init="handleFilePondInit"
    v-on:processfile="handleFilePondProcessFile"
    v-on:removefile="handleFilePondRemoveFile"
    v-bind:server="{
        process: $page.props.filepondServerUrl,
        revert: $page.props.filepondServerUrl,
        headers: {
            'X-CSRF-TOKEN': $page.props.csrfToken,
        },
    }"
    credits="false"
    aria-describedby="helper-text-filepond"
/>

Can you reproduce the error?
I am willing to provide further information if necessary.

Thank you very much for the work you have done and for providing this package!

Error at nested validation

Hello.

In case at nested validation rules like:

public function rules()
{
  return [
   'variants.*.image' => Rule::filepond([
                'image',
                'mimes:jpeg,jpg,png',
                'max:8000',
            ]),
  ];
}

I had error

Argument #1 ($data) must be of type string, array given, called in /var/www/html/vendor/rahulhaque/laravel-filepond/src/AbstractFilepond.php on line 52

At AbstractFilepond.php on line 52 in debug mode i see:
Xnip2023-10-08_19-25-22

Its bug or i do something wrong?

Unable to manually delete temporary files.

I had a job to create a "post", after the post is created all the temporary files should be deleted. But weird things happened, pls look at the codes.

public function handle(): void
    {
        $showcase = new Showcase([
            "uuid" => $this->uuid->toString(),
            "title" => $this->title,
            "description" => $this->description,
            "slug" => Str::slug($this->title),
        ]);

        $showcase->authoredBy($this->author);
        $showcase->save();

        $showcase_cover_image = Filepond::field($this->showcase_cover_image); // single upload
        $showcase_images = Filepond::field($this->showcase_images); // chunk upload 
        
        $showcase_cover_image->delete(); // this is not deleted 
        $showcase_images->delete(); // this is deleted
    }

File does not exist or is not readable

This is the validation rule

'images' => ['array'],
'images.*' => ['required', Rule::filepond([
    'required',
    'file',
    'mimes:jpeg,png,jpg,gif,pdf',
    'max:20000'
])]

I'm also using only web middleware because it's a public access.

'middleware' => [
'web',
], 

But, I got a validation error like the following everytime

"File does not exist or is not readable: eyJpdiI6IndaNEx3NVlRc1JhM3FFNVpoSU9pMXc9PSIsInZhbHVlIjoid2VOWmE4WHRWQjhGMTlHOHBNNE12VkZKOVZFcEU5b09tbG15aHhadEw5az0iLCJtYWMiOiIxNDM5MThiNzkyMWQ3MzFmODI5ZTk3ZDQ0MzQxYjQ0ZmViM2Q1OGUwYzc0Y2JhNGU5ODljYjQzNjVjOTVjZDM4IiwidGFnIjoiIn0="

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.