{"_id":"563c907319ae7b0d0050d528","version":{"_id":"563b65bd9e3f2225009fd2bf","project":"563b65bd9e3f2225009fd2bc","__v":4,"createdAt":"2015-11-05T14:20:45.639Z","releaseDate":"2015-11-05T14:20:45.639Z","categories":["563b65be9e3f2225009fd2c0","563b6b25e951f60d000b4513","563c239e260dde0d00c5e890","563c2440260dde0d00c5e891"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"4.0.0","version":"4.0"},"__v":12,"project":"563b65bd9e3f2225009fd2bc","parentDoc":null,"user":"563b65409e3f2225009fd2b9","category":{"_id":"563b6b25e951f60d000b4513","version":"563b65bd9e3f2225009fd2bf","__v":6,"pages":["563c21fd19ae7b0d0050d45b","563c220c7539dd0d00dbee87","563c2218ac77910d00279fe7","563c2233d8f2d20d00448b4f","563c2376913e650d00b65dbd","563c907319ae7b0d0050d528"],"project":"563b65bd9e3f2225009fd2bc","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-11-05T14:43:49.565Z","from_sync":false,"order":1,"slug":"the-basics","title":"The Basics"},"updates":["5805fbd87f46c10f004b2fb8"],"next":{"pages":[],"description":""},"createdAt":"2015-11-06T11:35:15.350Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"The package allows the user to upload and download images through means of multiple and single entries into the website.\n\nThe basic model for the package can be implemented through the following code. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?\\n\\nuse Litepie\\\\Database\\\\Model;\\nuse Litepie\\\\Filer\\\\Traits\\\\Filer;\\n\\n....\\n\\nclass YourModelClass extends Model\\n{\\n    use Filer ...;\\n\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Implementing the File Upload Function\"\n}\n[/block]\nThe model has a **config** file.\n\nThe code that must be implemented in order implement the file upload function is as follows.\n\nThe code can be divided as an single and multiple, as decided by the user. \n\nEg. Single can be used to implement a profile picture, while multiple selection can be implemented for a photo gallery. \n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?\\n\\n// Model variables for module variable.\\n'model'     => [\\n    ........\\n    'uploadfolder' => '/uploads/page',\\n\\n    'uploads'      => [\\n        'single'   => ['single_file_field_1', 'single_file_field_2'],\\n        'multiple' => ['multiple_file_field_1', 'multiple_file_field_2'],\\n    ],\\n\\n\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"File Upload Interface\"\n}\n[/block]\nThe file upload interface can be generated on the user side, implementing the following code. The would be open to allowing the user to upload all types of files.\n\nA further iteration on choosing a particular type of files (Eg. Images, Word, Excel) can be done ahead. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?\\n\\n{!! Filer::uploader('multiple_file_field_1', $page->getUploadURL('multiple_file_field_1')) !!}\\n\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Single VS Multiple Upload\"\n}\n[/block]\nThe following code can be found once the file has been uploaded in a JSON format online. \n\nThe code for the multiple upload would be as follows. \n\nThe data would consist of Folder Name, File Name, Caption, Time & EFolder. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\nMultiple\\n[  \\n   {  \\n      \\\"folder\\\":\\\"\\\\/uploads\\\\/pages\\\\/2016\\\\/05\\\\/07\\\\/050447617\\\\/images\\\\/\\\",\\n      \\\"file\\\":\\\"file.jpg\\\",\\n      \\\"caption\\\":\\\"File\\\",\\n      \\\"time\\\":\\\"2016-05-11 04:46:48\\\",\\n      \\\"efolder\\\":\\\"pages\\\\/066zCXfgcnxBl0\\\\/images\\\"\\n   },\\n   {  \\n      \\\"folder\\\":\\\"\\\\/uploads\\\\/pages\\\\/2016\\\\/05\\\\/07\\\\/050447617\\\\/images\\\\/\\\",\\n      \\\"file\\\":\\\"file-2.png\\\",\\n      \\\"caption\\\":\\\"File 2\\\",\\n      \\\"time\\\":\\\"2016-05-11 04:46:49\\\",\\n      \\\"efolder\\\":\\\"pages\\\\/066zCXfgcnxBl0\\\\/images\\\"\\n   }\\n]\\n\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe following lines of code can be found for a single uploaded file.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\nSingle\\n{  \\n  \\\"folder\\\":\\\"\\\\/uploads\\\\/pages\\\\/2016\\\\/05\\\\/07\\\\/050447617\\\\/images\\\\/\\\",\\n  \\\"file\\\":\\\"file-2.png\\\",\\n  \\\"caption\\\":\\\"File 2\\\",\\n  \\\"time\\\":\\\"2016-05-11 04:46:49\\\",\\n  \\\"efolder\\\":\\\"pages\\\\/066zCXfgcnxBl0\\\\/images\\\"\\n}\\n\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe following can be implemented in order to return the URL required for uploading the respective files.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?\\n\\n$page->getUploadURL('field_name'))\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]","excerpt":"Manage file upload and image resizing.","slug":"filer","type":"basic","title":"Filer"}

Filer

Manage file upload and image resizing.

The package allows the user to upload and download images through means of multiple and single entries into the website. The basic model for the package can be implemented through the following code. [block:code] { "codes": [ { "code": "<?\n\nuse Litepie\\Database\\Model;\nuse Litepie\\Filer\\Traits\\Filer;\n\n....\n\nclass YourModelClass extends Model\n{\n use Filer ...;\n", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "Implementing the File Upload Function" } [/block] The model has a **config** file. The code that must be implemented in order implement the file upload function is as follows. The code can be divided as an single and multiple, as decided by the user. Eg. Single can be used to implement a profile picture, while multiple selection can be implemented for a photo gallery. [block:code] { "codes": [ { "code": "<?\n\n// Model variables for module variable.\n'model' => [\n ........\n 'uploadfolder' => '/uploads/page',\n\n 'uploads' => [\n 'single' => ['single_file_field_1', 'single_file_field_2'],\n 'multiple' => ['multiple_file_field_1', 'multiple_file_field_2'],\n ],\n\n", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "File Upload Interface" } [/block] The file upload interface can be generated on the user side, implementing the following code. The would be open to allowing the user to upload all types of files. A further iteration on choosing a particular type of files (Eg. Images, Word, Excel) can be done ahead. [block:code] { "codes": [ { "code": "<?\n\n{!! Filer::uploader('multiple_file_field_1', $page->getUploadURL('multiple_file_field_1')) !!}\n", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "Single VS Multiple Upload" } [/block] The following code can be found once the file has been uploaded in a JSON format online. The code for the multiple upload would be as follows. The data would consist of Folder Name, File Name, Caption, Time & EFolder. [block:code] { "codes": [ { "code": "\nMultiple\n[ \n { \n \"folder\":\"\\/uploads\\/pages\\/2016\\/05\\/07\\/050447617\\/images\\/\",\n \"file\":\"file.jpg\",\n \"caption\":\"File\",\n \"time\":\"2016-05-11 04:46:48\",\n \"efolder\":\"pages\\/066zCXfgcnxBl0\\/images\"\n },\n { \n \"folder\":\"\\/uploads\\/pages\\/2016\\/05\\/07\\/050447617\\/images\\/\",\n \"file\":\"file-2.png\",\n \"caption\":\"File 2\",\n \"time\":\"2016-05-11 04:46:49\",\n \"efolder\":\"pages\\/066zCXfgcnxBl0\\/images\"\n }\n]\n", "language": "json" } ] } [/block] The following lines of code can be found for a single uploaded file. [block:code] { "codes": [ { "code": "\nSingle\n{ \n \"folder\":\"\\/uploads\\/pages\\/2016\\/05\\/07\\/050447617\\/images\\/\",\n \"file\":\"file-2.png\",\n \"caption\":\"File 2\",\n \"time\":\"2016-05-11 04:46:49\",\n \"efolder\":\"pages\\/066zCXfgcnxBl0\\/images\"\n}\n", "language": "json" } ] } [/block] The following can be implemented in order to return the URL required for uploading the respective files. [block:code] { "codes": [ { "code": "<?\n\n$page->getUploadURL('field_name'))", "language": "php" } ] } [/block]