Welcome Guest, Not a member yet? Register   Sign In
PLzz Help me to solve my problme related to uploading using flash
#1

[eluser]Patu[/eluser]
i have problem when i uploading somthing using flash i get Upload Failed(-200): 302 error.

I attached my controller,model and view.
#2

[eluser]Patu[/eluser]
<!-- Controller -->

<?php
class File extends Controller {

function File()
{
parent::Controller();
$this->load->library('ion_auth');
$this->load->model('file_model');
$this->load->library('form_validation');
$this->load->library('session');
$this->load->database();
$this->load->helper('url');
}

function index()
{
if (!$this->ion_auth->is_admin())
{
//redirect them to the home page because they must be an administrator to view this
redirect($this->config->item('base_url'));
}

//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');

//list the file
$this->data['files'] = $this->file_model->getall();
$this->data['categories'] = $this->file_model->getallcategories();
//print_r($this->data);exit;
$this->load->view('files/view_file', $this->data);
}

function create_file()
{
.....
}

function edit_file($id=null,$type =null)
{
.....
}

function delete_file()
{
......
}

function cat_name_check($str)
{
......
}

public function upload($secid=0)
{
if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
{
redirect('auth');
}

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'avi|mp3|wmv|jpg|jpeg|png';//$this->startup->group_config->files_types;
$config['max_size'] = 500;//(1024 * intval($this->startup->group_config->upload_size_limit));

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

if($this->upload->do_upload()) {
$data = array('upload_data' => $this->upload->data());

$this->file_model->upload($data,$secid);

echo "WIN";
} else {
echo "FAIL";
}
}

public function getLinks($secid)
{
$data['link'] = $this->file_model->getLinks($secid);
$this->load->view('file/links', $data);
}
}?>
#3

[eluser]Patu[/eluser]
<!-- Model -->

<?
if(!class_exists('CI_Model')) { class CI_Model extends Model {} }

class file_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->config('ion_auth', TRUE);
$this->load->helper('cookie');
$this->load->helper('date');
$this->load->library('session');
$this->load->library('functions');
}

public function getall()
{
return $this->db->get('files');
}

public function getparticuler($id)
{
$this->db->where('id',$id);
return $this->db->get('files');
}

public function check_duplicate($cat_name)
{
....
}

public function insert($data,$tags)
{
....
}

public function update($id, $data, $tags)
{
....
}


public function delete($id)
{
....
}

public function upload($data) {
$data_col = array('user_id' => $this->session->userdata('user_id'),
'file_name' => $data['filename'],
'file_size' => $data['filesize'],
'file_md5' => md5_file($data['file'])
);
$this->db->insert('files', $data_col);
}

public function getLinks($secid)
{
$this->db->where('secid',$secid);
$query = $this->db->get('refrence');
$file = $query->row();
return $file->o_filename;
}
}
?>
#4

[eluser]Patu[/eluser]
click on: http://pastebin.com/zE4CYdrR
#5

[eluser]Patu[/eluser]
http://pastebin.com/zE4CYdrR
#6

[eluser]Patu[/eluser]
plzzzzzz
#7

[eluser]davidbehler[/eluser]
I might have an idea what the problem is: In your upload function you check wether the current user is logged in and if he's not you redirect to /auth. So far so good except that the Flash request (that does the upload and all) has it's own session and even though the user trying to upload might be logged in, the "flash-user" is not.

So my first suggestion would be to remove the login check from the upload function (for now) and later you can think of some way to make it more secure.
#8

[eluser]Patu[/eluser]
thnx




Theme © iAndrew 2016 - Forum software by © MyBB