Ad

Upload A Template File (Eg: Home.php, Home.html Etc...) In Views Folder In Codeigniter Via File-upload

I have a CMS project in CodeIgniter. In admin panel have a form called add pages section where I need to upload a file to views folder i.e. root->Applications->views

Is it possible?

application - model - views (upload files here via coding) - controller

Ad

Answer

Please be guided.

Controller:

public function sample(){
    $this-><Model_Name>->save_data($_POST,$_FILES);
}

Model:

public function save_data($data,$fetchFile){
    extract($data);
    $col_file = <name of the input type file>;
    $directory = "C:/xampp/htdocs/<project_name>/application/views/";
    $file_name=$fetchFile[col_file]["name"];
    $file_tmp=$fetchFile[col_file]["tmp_name"];
    move_uploaded_file($file_tmp=$fetchFile[col_file]["tmp_name"],$directory.$file_name);
}
Ad
source: stackoverflow.com
Ad