This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Is there any solution to get the full file path of a just uploaded image in the backend?
I need to paste the image url in afterCreate() When I use $image->getPath() I get the follow error: "Call to a member function getPath() on a non-object"
If i try $request->file('featured_image') give me also the "Call to a member function file() on a non-object"
I try also Input::file('featured_image')->getRealPath() what give me also "Call to a member function getRealPath() on a non-object"
Is there any way to get the full file path of a just uploaded image in the backend?
Wouter said:
Is there any solution to get the full file path of a just uploaded image in the backend?
I need to paste the image url in afterCreate() When I use $image->getPath() I get the follow error: "Call to a member function getPath() on a non-object"
If i try $request->file('featured_image') give me also the "Call to a member function file() on a non-object"
I try also Input::file('featured_image')->getRealPath() what give me also "Call to a member function getRealPath() on a non-object"
Is there any way to get the full file path of a just uploaded image in the backend?
Have you solved this case? I feel crazy because of it.
Please tell me if you have solved this.
Wouter said:
Is there any solution to get the full file path of a just uploaded image in the backend?
I need to paste the image url in afterCreate() When I use $image->getPath() I get the follow error: "Call to a member function getPath() on a non-object"
If i try $request->file('featured_image') give me also the "Call to a member function file() on a non-object"
I try also Input::file('featured_image')->getRealPath() what give me also "Call to a member function getRealPath() on a non-object"
Is there any way to get the full file path of a just uploaded image in the backend?
Have you solved this case? I feel crazy because of it.
Please tell me if you have solved this.
Wouter said:
I use the media manager that was een better way for me...
Could you give me how to implement with media manager?
Thanks
Fibonacci said:
Wouter said:
I use the media manager that was een better way for me...
Could you give me how to implement with media manager?
Thanks
What exactly are you planning to do? If you use the mediamanager, it will store a string
in the database, instead of using the filesystem. I'm guessing right now, but in the afterSave
method you can reference this and do something with it.
Remember, you need to edit your database for this!
Docs: https://octobercms.com/docs/backend/forms#widget-mediafinder
Rebel59 said:
Fibonacci said:
Wouter said:
I use the media manager that was een better way for me...
Could you give me how to implement with media manager?
Thanks
What exactly are you planning to do? If you use the mediamanager, it will store a
string
in the database, instead of using the filesystem. I'm guessing right now, but in theafterSave
method you can reference this and do something with it.Remember, you need to edit your database for this!
Docs: https://octobercms.com/docs/backend/forms#widget-mediafinder
I'm planning to get the dominant color of picture using this package https://github.com/ksubileau/color-thief-php. I can do that in front end. Because I can get the full path of it. But, in backend, I tried many ways and still can't.
It seems easy to do that using mediafinder. But, I have a few question:
- Is it possible to do in front end too?
- Is it possible to use getThumb method to resize the image from mediafinder? Like when I used System\Models\File.
Mediafinder stores the image as a string
. As far as I know it is not possible to perform these methods as they belong to the file
model.
I'll try and see if I can get it to work.
What I've found out so far:
Fact: $this->image->getPath()
works if there is already an image present.
Say: If you first save the image WITHOUT the afterSave
method. This will successfully save the image to the filesystem. After you have done this, you can add the afterSave
method again. If you execute $this->image->getPath
it will return the path of the image.
Will keep you updated about any progress. Might be a bug, who knows...
I'm not sure. What you can do is implement media finder
instead of the file system. That does work.
I can access the image if I use media finder. In the afterSave
method, $this->image
returns something like /image.png
. If you prepend www.yourwebsite.tld/storage/app/media
you can access the image from anywhere.
Maybe @daftspunk reads this sometime in the future and explain why the file system way doesn't work.
Hope this helps.
Last updated
Hello, how do I have a similar problem like I can save the image url to a table that I create with the builder and tried everything but I can not find a solution
Config::get('cms.storage.uploads.path')
if the file is uploaded via media manager use
Config::get('cms.storage.media.path')
If u want the url use the url(somePath) helper
For exemple in one of my Model
/**
* get media base URL
*
* @return string
**/
public function getMediaURLAttribute()
{
$baseUrl = url(Config::get('cms.storage.media.path'));
return $baseUrl;
}
1-14 of 14