rahulhaque / laravel-filepond Goto Github PK
View Code? Open in Web Editor NEWUse FilePond the Laravel way.
License: MIT License
Use FilePond the Laravel way.
License: MIT License
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:
laravel-filepond/src/Filepond.php
Line 185 in a3bfa1b
I think replacing the Filesystem::get()
to read the contents of the file with Filesystem::readStream()
could fix this issue.
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 !
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 ?
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?
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.
chunk upload isn't working. Is it possible now to upload large files in chunks using this package ?
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
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 :(
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
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);
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.
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']);
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.
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.
Changes made in fb98916 add union types to several method arguments so the project no longer works with PHP 7.3.
This is still an option defined in the composer.json so should be amended or reverted depending on the desired supported versions.
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
imageTransformVariants doesn't send multiple files to the controller as It supposes to. Is there anything I missed?
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>
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.
How use style filepond? because i am now use cdn for style
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
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
laravel-filepond/src/Filepond.php
Lines 153 to 171 in 886ac39
there is a missing else case, since $filepond = $this->getFieldModel();
returns a Collection, it tries calling ->delete() on a Collection instance.
Can you please make a release for laravel 6?
Will this package support laravel 11?
Hello everyone,
I have encountered the following 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
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',
]),
],
];
}
"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",
...
}
<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!
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:
Its bug or i do something wrong?
Hi, I links to laravel versions like this:
https://github.com/rahulhaque/laravel-filepond/tree/10.x
are broken, because they all show the same home page
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
}
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="
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.