Ca ne m'affiche rien.. Je pense que je n'y ai pas mis au bon endroit.
En fait lors de l'ajout il me l'ajoute le fichier zip.
Par contre quand je clique sur le lien qui est censé me rediriger vers ce fichier dans l'url j'ai :
http://blablablabla.com/statics/contenus/0
Alors que quand j'ajoute un pdf l'url est :
http://blablablabla.com/statics/contenus/2108300212.pdf
Voilà mon controllers :
class News extends Controller {
function __construct()
{
parent::Controller();
$this->load->library('eggcetera');
}
function index()
{
$data = array();
$data['title'] = 'Les news';
$data['template'] = 'back/news/list';
$this->load->model('Mnew');
$data['news'] = $this->Mnew->get_news();
$this->load->view('template_back', $data);
}
function ajouter()
{
$data = array();
/* Informations de la page */
$data['title'] = "Ajouter une new";
/* Template à afficher */
$data['template'] = "back/news/add";
/* Vérification du post */
$title = trim($this->input->post('title'));
$content = trim($this->input->post('content'));
$this->form_validation->set_rules('title', '"Titre"', 'trim|required');
$this->form_validation->set_rules('content', '"Contenu"', 'trim|required');
/* Insertion dans la base de données */
if($this->form_validation->run())
{
$this->load->model('Mnew');
$path_to_file = false;
$config['upload_path'] = './statics/contenus/';
$config['allowed_types'] = 'zip';
$config['max_size'] = '2000';
$config['encrypt_name'] = 'TRUE';
$this->load->library('upload', $config);
if ($this->upload->do_upload()) {
$data = array('upload_data' => $this->upload->data());
/* envoi fichier */
$result = $this->upload->data();
/* inscription dans la BDD */
$path_to_file = $result['file_name'];
}
$this->Mnew->insert_new($title, $content, $path_to_file);
redirect('administration');
}
/* Chargement de la page */
else
{
$this->load->view('template_back', $data);
}
}
function modifier($id)
{
$data = array();
/* Informations de la page */
$data['title'] = "Modifier une new";
/* Template à afficher */
$data['template'] = "back/news/modify";
/* Vérification pré-modification */
$this->load->model('Mnew');
$new = $this->Mnew->get_new_by_id($id);
if($new !== false)
{
/* Contenu à transférer */
$data['new'] = $new;
/* Vérification du post */
$title = trim($this->input->post('title'));
$content = trim($this->input->post('content'));
$this->form_validation->set_rules('title', '"Titre"', 'trim|required');
$this->form_validation->set_rules('content', '"Contenu"', 'trim|required');
/* Chargement de la page */
if($this->form_validation->run())
{
$path_to_file = $new->file;
$config['upload_path'] = './statics/contenus/';
$config['allowed_types'] = 'zip';
$config['max_size'] = '2000';
$config['encrypt_name'] = 'TRUE';
$this->load->library('upload', $config);
if ($this->upload->do_upload()) {
$data = array('upload_data' => $this->upload->data());
/* envoi fichier */
$result = $this->upload->data();
/* inscription dans la BDD */
$path_to_file = $result['file_name'];
}
$new->update($title, $content, $path_to_file);
redirect('administration');
}
else
{
$this->load->view('template_back', $data);
}
}
}
function supprimer($id)
{
$data = array();
/* Vérification pré-suppression */
$this->load->model('Mnew');
$new = $this->Mnew->get_new_by_id($id);
if($new !== false)
{
$new->delete();
}
redirect('administration');
}
}
Help please....