Welcome Guest, Not a member yet? Register   Sign In
Problem about Upload Filename into Database?
#1

[eluser]Unknown[/eluser]
Hi all,
i am a new CI. i has a problem about Upload file and save filename into Database.

Code:
Control
        class Blog extends Controller
{
// construction
    function Blog()
    {
    parent::Controller();
    $this->load->helper('date');
    $this->load->helper(array('form', 'url'));
    $this->load->library('upload');
    }

    function index()
    {
    $this->viewtopic();
    }

    function viewtopic()
    {
    $topic_list = $this->_topic_list();
    $data['body'] = $topic_list;
    $this->load->view('main' , $data);
    }

    function insert()
    {
    $blog_id = $_POST['blog_id'];
    $username = $_POST['username'];
    $comment = $_POST['comment'];
    $userfile = $this->input->post('userfile');
    //$userfile = $_POST['userfile'];
    $time = now();
        
    
    $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '50';
        $config['max_width'] = '100';
        $config['max_height'] = '100';

        $this->load->helper('form');
        $this->load->library('upload', $config);

    //echo "User:".$username."<br>Comment :".$comment."<br>Userfile :".$userfile."<br> Blog_id:".$blog_id;
    //exit();
        
    if(empty($comment) || empty($username))
    {
      show_error('Some field is blank!<br />Please <a href="[removed]history.back();">return</a>..');
    }
        
    $sql = "INSERT INTO `comments` (`blog_id` , `username` , `comment` , 'picture' , `time`) VALUES({$blog_id} , '{$username}' , '{$comment}' ,'{$userfile}' , {$time})";
    $this->db->query($sql);
        
    redirect('blog/viewblog/' . $blog_id);
    }
Problem :
1. I can not find filename for insert into SQL.
2. if i want another file. how i do?.

Thank.


Messages In This Thread
Problem about Upload Filename into Database? - by El Forum - 05-23-2008, 03:27 AM
Problem about Upload Filename into Database? - by El Forum - 05-23-2008, 04:09 AM
Problem about Upload Filename into Database? - by El Forum - 06-25-2008, 10:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB