Hie guys i am still learning cakephp so this question might be easy but im struggling. I have a view.ctp that is currently displaying a buyer's profile like personal details, in addition to this i also want it to display a profile picture for the buyer as well. I have a field in the buyers table called prof_pic which is using longblob data type. I can view the profile of the logged buyer, now i want them to view their profile picture and the personal details as well. How do i do this? Thank you
save image in folder
then you can easily use it ... resize or crop as you like ..
that's simple and easy way :)
You should consider saving your files in the filesystem instead of the database. Florian Krämer from CakeDC did a nice writeup of why to do this. In short:
Storing files in the database is in nearly all cases a bad solution
because when you get the file it has to go its way through the
database connection, which can, specially on servers that are not in
the same network, cause performance problems.
Advantages of storage in the file system:
Easy and direct file access, to parse them (csv, xml...) or manipulate them (images)
You don't need to install any additional software to manage them
Easy to move and mount on other machines
Smaller then stored in a DB
He started an interesting implementation of a plugin to do this. It makes use of the Gaufrette filesystem abstraction layer and makes working with files in Cake much cleaner. A way to scale Images to your needs with the Imagine plugin is also already provided and you're even able to host your images on Amazon S3 and the likes if you're running a high traffic site.
Related
I'm looking for a solution that allows multiple websites to share the same table/database for just the gallery page.
The scenario is that one website will host all the images uploaded while the other website will pull images from that site and filter them to only have the ones relevant to itself. I only want to share the table/database for just the gallery images and not other posts.
Does anyone know if there is a solution that already exists for this kind of problem?
Shared databases (it's called a remote database when accessing one not on your domain/server) are possible, but they tend to get pretty hairy very quickly.
You'd be better suited to use the WP REST API to query posts (if it's a custom post type (also note if it is a custom post type, you may need to register the endpoint on the API: Read more here)) or if it's media library files, you can query media directly using http://v2.wp-api.org/reference/media/
This exact scenario is almost exactly what the v2 API was designed to deal with, and it will save you an enormous amount of stress instead of relying on two installations working on the same database.
Alternatively, you could host the images on a CDN and make queries to the CDN based on that particular site's needs.
I just got some questions, maybe some of you can answer.
The benefit by Nextcloud / Owncloud and so on is more than just uploading taking files with you and so on.
It does version the files, make them downloadable - as well secure behind.
It would be benefitial for me and most everyone who is dealing with the Question:
"How to upload documents, link them in some kind of Database (which main purpose is to operate with information) and versioning, saving, editing and so on does not need to be implemented by me / others, because it is handled by Nextcloud (in my case prefered)?"
Is there any script outside, or maybe some kind of plugin to have that benefit?
In my vision I would need:
One "Drag and Drop" Area for Documents / Pictures etc.
This should have a hidden field, which is filled with a id, with which the system can identify the file.
a onetime Link (with retention of that link by one day or so) what is generated by php (could also be a script) and generates a share Link for given id.
(not needed since now, but nice to have:) some script as in 2, where versions of some given File should be viewed.
Some solution could be:
something similar to an "iframe" for a shared link with public upload.
But Im not very happy of using IFrames... Something better would be nice.
Drag & Drop is available in the Web UI. For additional meta data, use a hook mechanism on postCreate (\OCP\Files\Node $node) within a custom app/module you'd need to deploy. For hooks, see https://docs.nextcloud.com/server/12/developer_manual/app/hooks.html.
About meta data: you don't need to store them in a database necessarily, you can also use custom WebDav properties. I wrote a blog post about it recently: https://medium.com/#mathiasconradt/how-to-assign-custom-meta-data-to-your-documents-on-nextcloud-23356cf3f926
Links with a time limit to be valid can be generated manually via Web UI. If you need it automated on upload, use the same approach as in (1): hook mechanism that listens to file creations, as part of a custom app.
at the moment, you can only restore old versions. I think you cannot diff/view them. Would require a custom app.
General info on how to write your own module / app: https://docs.nextcloud.com/server/12/developer_manual/app/index.html
In my app many users, and they can add articles, articles can contain images, and all images stored in uploads folder, and by default any user can delete any image in folder, certanly its not good, whats is the best way to fix that
(For example store images in uploads//) or something like that?
Problem is - how i can separate user uploads?
Since you included the tag yii have a look at Authentication and Authorization - Yii framework. It has special support on this topic. Try to stick with your frameworks conventions to achieve what you desire first. This way you'll have a conssistent system and the power of frameworks' community.
We have a web application that we're refactoring. We want to make an environment per version with different users (companies) that share the same codebase.
It know this is a somewhat simple question but I just want to make sure we make the right decision (according to webapp best practice).
Say companya.webapp.com points to /1.00/public
and companyb.webapp.com points to /1.30/public
I'm wondering what the best way is to store custom data from these users. Custom data could be uploaded documents, photos and also generated static data like PDF documents/invoices.
When I migrate a user to a different version I want his data to be available in the other version too. The documents also have a record in the database with the path description.
Would it be OK to do something like this structure:
/data/[companyname]/pictures
/data/[companyname]/documents
/data/[companyname]/documents/pdf
/data/[companyname]/documents/csv
/1.00/public
Sure, use whatever structure you like. There's no real "correct" answer, and it's very hard to do it wrong. Just make sure the permissions are properly set, so that each company can't read each other's files.
Using PHP i want to create a picture gallery, i need a few suggestion on what would be the best logical solution for this.
a) create a directory for an album and move all the related pictures into the directory and henceforth follow the same way for other albums
b) keep a record or the path using the database(MySQL) and use the relational table (album).
for the method a . is there any way to deal the picture gallery without actually having the need to use the database or XML or whatsoever(database).?
what is your take on this?
thank you.
IMO the database route is the one to take, as it will be much more extensible and easier to maintain.
If you decide to add in a rating/description/review/[whatever] at a later date you will have the foundations in place.
you can still create a directory for each album - WordPress adopts this kind of practice (/uploads/2010/10) for instance - (directories for each month)
you could do it without a database, through some means of directory traversal and an imaginative naming scheme - if you wanted to sort or search the images some common naming format would be needed. Plus you are very restricted on meta data.
+1 for database from me. You ~can~ even store the images in the DB. but I prefer to keep them as images and just link to the path.
my $0.02
Personally, I would do a combination of both. You will want to move the pictures into a folder structure that makes sense. Whether or not that is by user or by album or what, that is up to you.
You could potentially use method A and ditch the database by keeping each gallery in a properly named folder and then just open that folder and loop through the contents every time you wanted to display the gallery, but it would make your life much more difficult and it wouldn't make much sense.
By using a database, you have all the benefits of a relational data structure... photos can be linked to galleries and tags can be applied to photos.. you can store permissions by photo or by gallery... you have way more options when going with the database.