• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
user profile

#1
i can't upload a photo and save into my databse
my controller is

Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Main extends CI_Controller {
public function __construct() {
    parent::__construct();

    // Load form helper library
    $this->load->helper('form');

    // Load session library
    $this->load->library('session');

    // Load database
    $this->load->model('Login_Database');
    }

public function index(){
    
    $this->load->view('main');
    $this->load->model('Login_Database');
}

public function save(){
$url=$this->do_upload();

$this->Login_Databse->save($url);

}
private function do_upload(){
$type=explode(".",$_FILES["pic"]["name"]);
$type=$type(count($type)-1);
$url="./images/".uniqid(rand()).','.$type;
if(in_array($type,array("jpg","jpeg","gif","png")))
    if(is_uploaded_file($_FILES["pic"]["tmp_name"]))

        if(move_uploaded_file($_FILES["pic"]["tmp_name"],$url))
return $url;
return "";
}


}
Reply

#2
What error message are you getting?

ps - edited your post, adding code tags so it would not be TL;DR
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.