[eluser]Unknown[/eluser]
Hello I have a problem with my code
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller{
public $name = 0;
public function upload_file()
{
$status = "";
$msg = "sunt din site";
$file_name = "";
$file_element_name = 'userfile';
$config['upload_path'] = './files/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1024 * 8;
$config['max_width'] = 300;
$config['max_height'] = 215;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if (!$this->upload->do_upload($file_element_name)){
$status = 'error';
$msg = $this->upload->display_errors('', '');
}else{
$data = $this->upload->data();
$msg = $data['file_name'];
setname($msg);
$file_name = $data['orig_name'];
/*
$this->load->model('upload');
$file_id = $this->upload->insert_file(
*/
@unlink($_FILES[$file_element_name]);
}
}
public function setname($data){
$this->name = $data;
}
The problems sounds like that, I`m making ajax uploading and i want to check the name of the file uploaded before, and for that i made a global pulic name and i want to set it but it doesn't work, how should i do that?