[eluser]Lamonte[/eluser]
Basically, if I don't fill in the input box, I get both errors, no file selected and this field is required:
Code:
public function add()
{
$config['upload_path'] = './uploads/'; //str_replace("\\","/",BASEPATH . 'uploads/');
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->instance->upload->initialize($config);
$this->form_validation->set_rules('name', 'Project Name', 'required');
if( !$this->instance->upload->do_upload() && ( $this->form_validation->run() == FALSE))
{
$this->template->load( array(
array(
"admin/modules/folio/add",
array('upload' => $this->instance->upload->display_errors()),
),
),"admin");
}
else
{
//save data in db
}
}
When I fill in the input box, not the file input, it submits successfully, yet I didn't even select a file to upload...
Code:
<?php echo anchor("/admin/module/folio/","Manage Projects"); ?> | <?php echo anchor("/admin/module/folio/add","Add Project"); ?>
<h2>Add Project</h2>
<?php echo $upload; ?>
<?php echo validation_errors(); ?>
<?php echo form_open_multipart("admin/module/folio/add"); ?>
<table width='100%' cellspacing='2' cellpadding='2'>
<tr>
<td width='30%'>Project Name (Website)</td>
<td><?php echo form_input(array('name' => 'name')); ?></td>
</tr>
<tr>
<td>Preview IMG <small>500x300 px</small></td>
<td><input type="file" name="userfile" size="20" /></td>
</tr>
<tr>
<td>Service: <small>Designed?</small></td>
<td><?php echo form_checkbox(array('name' => 'design')); ?></td>
</tr>
<tr>
<td>Service: <small>Created Logo?</small></td>
<td><?php echo form_checkbox(array('name' => 'logo')); ?></td>
</tr>
<tr>
<td>Service: <small>(X)HTML?</small></td>
<td><?php echo form_checkbox(array('name' => 'xhtml')); ?></td>
</tr>
<tr>
<td>Service: <small>CSS?</small></td>
<td><?php echo form_checkbox(array('name' => 'css')); ?></td>
</tr>
<tr>
<td>Service: <small>PHP?</small></td>
<td><?php echo form_checkbox(array('name' => 'php')); ?></td>
</tr>
<tr>
<td colspan='2'><?php echo form_submit("submit","Add Project"); ?></td>
</tr>
</table>
<?php echo form_close(); ?>