[eluser]Clooner[/eluser]
I use the upload library but somehow it says the directory is not correct. I checked this using the file helper and writing a file to that directory. Writing the file works so, I must be overlooking something in the upload library. Anyone ideas?
Code:
function images($id)
{
// get the correct data
if ($this->prep_for_edit($id))
{
// check if path exists! or else create it!
if (!is_dir(img_path().$id))
mkdir(img_path().$id,0777);
// TODO: remove, test if I can write data!
$fdata = 'Some file data';
$this->load->helper('file');
if ( ! write_file(img_path().$id.'/'.date('lHis').'.txt', $fdata))
$this->data['debug']['writable'] = 'Unable to write the file';
else
$this->data['debug']['writable'] = 'File written!';
// overwrite the default form
$this->data['form']['submit'] = "Foto uploaden";
$this->data['form']['type'] = "multipart";
$config['upload_path'] = img_path().$id;
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = '2048';
$config['max_width'] = '1600';
$config['max_height'] = '1200';
$config['overwrite'] = 'TRUE';
$this->load->library('upload', $config);
// TODO: remove next line
$this->data['debug']['config']=$config;
if (!empty($_FILES))
{
// TODO: remove next line
$this->data['debug']['files']=$_FILES;
if ($this->upload->do_upload('produce_image'))
{
// TODO: remove next line
$this->data['debug']['uploadsuccessdata']=$this->upload->data();
$this->data['messages']['information'][]="Foto succesvol geupload";
} else
{
// TODO: remove next line
$this->data['debug']['uploadfaileddata']=$this->upload->data();
$this->data['messages']['error']=array_merge($this->data['messages']['error'],$this->upload->error_array());
}
}
$this->data['section']['content'][] = 'form_editor';
// TODO: remove next line
$this->data['section']['content'][] = 'debug_data';
}
}