Welcome Guest, Not a member yet? Register   Sign In
File Upload Help!
#1

[eluser]Unknown[/eluser]
Im new to CI and I think it can really help me
through a lot of things. However, When I tried one of its classes,
(File Uploading Class) on the manual, It's not working.
A
#2

[eluser]James Gifford[/eluser]
Can you provide some of your code?
#3

[eluser]Unknown[/eluser]
<!--This is my controller-->
/* 1st of all, theres some validation before i upload the files.
where exactly should I incorporate the File upload class?

*/
$this->erkanaauth->checkValidRoles(($profileid == 0 || isAuthEditable($profileid)) ? 'AUTH' : 'ADMIN');
$this->load->helper('form');
$this->load->library('validation');

$this->load->model('Users_model');

$rules['firstname'] = "trim|required";
$rules['lastname'] = "trim|required";
$rules['email'] = "trim|required|valid_email";
$rules['batchyear'] = "required|numeric";

$this->validation->set_rules($rules);

$fields['firstname'] = 'First name';
$fields['lastname'] = 'Last name';
$fields['address'] = 'Address';
$fields['spousename'] = 'Husband\'s name';
$fields['spousenumber'] = 'Husband\'s contact number';
$fields['description'] = 'Short description';
$fields['email'] = 'Email';
$fields['landline'] = 'Landline';


$this->validation->set_fields($fields);
$this->validation->set_error_delimiters('', '<br/>');

if ($this->validation->run() == FALSE)
{
$profileid = ($profileid > 0) ? $profileid : $this->session->userdata('user_id');

$userData = $this->Users_model->getUser($profileid);
$positions = $this->Users_model->getPositions($profileid);

$options['auth'] = array('AUTH' =>'Regular', 'ADMIN' => 'Administrator');
$options['type'] = array('ALUMNI' =>'Alumni', 'RESIDENT' => 'Resident');

$this->template->load(
'mainview',
'members/edit',
array(
'userdata' => $userData,
'options' => $options,
'positions' => $positions,
'sidebar_contents' => 'profileedit'
)
);
}
else
{
/*Is it ok to do upload chores here?

*/

$this->Users_model->updateUser($profileid, $_POST);
if ($profileid == $this->session->userdata('user_id')){
redirect('myprofile');
}
else {
redirect('viewprofile/' . $profileid);
}
}




&lt;!-- this is my view --&gt;
<p class="label" id="label_photo" style="">Upload Photo:</p>
&lt;form method="post" action="&lt;?=base_url()?&gt;users/edit/&lt;?=$userdata-&gt;userid?&gt;" enctype="multipart/form-data" />
&lt;input class="input_file" id="image_upload" type="file" &gt;

<p align="right">
&lt;input class="input_submit" type="submit" value="Save"&gt;
&lt;/form&gt;




Theme © iAndrew 2016 - Forum software by © MyBB