i am working on a Cakephp 2.x ... well i have new to cakephp and have never worked on saving the media files e.g music,images .. even not in simple php ... so the problem is i am sending images from my android app to my web-app ... i want to store those images in some private folder which would not accessible to everyone.. so i mean i don't want to store the images in webroot.. and then want to store the reference in the db ... so the first thing what i want to know is what is the standard way to store the images in cakephp... where should i create a folder of images ... and how to give the path of that ... inshort if anyone has implemented this or have code then please share...
write now i am getting the data from an android app is like this
public function mobileNo(){
if ($this->request->isPost()){
$json = $this->request->data('json');
$data = json_decode($json, TRUE);
$this->request->data['Calllog']['mobileNo'] = $datas['mobileNo'];
$this->Calllog->save($this->request->data);
}
}
public function images(){
if ($this->request->isPost()){
//
}
}
well one thing i want to mention that please dont refer me to some plugins or components because i things third party plugins or components make app slower.. so but if there is not any way then share it
because i things third party plugins or components make app slower
Why? If you get crappy written code this might be true but as a programmer you should be able to review, test and even measure the performance of code by profiling it if needed to find bottlenecks. And make a decision if the code is ok to use or not. What plugin slowed your app down?
Your question can not be answered with the snipped you provide, it does not show how the file data is received by the app. Does it appear as a regular file upload in php? Is it maybe somehow encoded binary data in a field? Further the question can not really be answered within a reasonable amount of text and time IMHO.
You already say that you don't want to use 3rd party code but prefer to reinvent the wheel and that you want to keep references to the DB. Well then do it you already said everything, so implement it. If you reconsider to use 3rd party code keep reading.
About the CakePHP side of the question, CakePHP sadly does not know a standard folder for uploads or comes with code to handle file uploads. Neither it has a good storage system so I've written a plugin (that performs fine, a well known brand is using it). I've spent some time on building this with the goal to create the most flexible file storage system for CakePHP. It handles each file as a separate entity (DB record) that can be associated with everything through the assocs of the CakePHP models.
I've seen lots of projects that did a bad job in my opinion by storing the file info, mostly only the path + filename inside the table and record that is directly related. But a file represents an entity on its own and has a little more meta data that matters (mime type, filesize...).
The plugin, without further configuration stores files (if you use the local filesystem) in APP/tmp/ as this is in a proper configured app setup the only writeable folder. I usually create a FileStorage folder inside the app to where all files are uploaded. Then I symlink folders that should be public to webroot/. But the plugin supports also S3 and other storage systems.
To download the file from your local server use the MediaView to pass it through php from a folder that is not public accessible.