I’m fighting with this already 1 and a half hour, but can’t find a problem. I’m using codeigniter and upload function, but it always fails to upload –
Controller –
// Uploads the picture to server
public function uploadPicture()
{
$this->load->helper(array('form', 'url'));
$this->load->helper('url');
$config['upload_path'] = './images/pictures/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '700';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$this->upload->do_upload();
if ( ! $this->upload->do_upload())
{
$data = array('upload_data' => $this->upload->data());
var_dump($data);
//redirect('/profile/changePicture', 'refresh');
}
else
{
redirect('/profile/changePicture', 'refresh');
}
}
view –
<form class="fix-this form" method="post" action="/savieno/profile/uploadPicture" enctype="multipart/form-data">
<div class="formfield">
<label id="current-password-error" class="input-error" style="display: none;"></label>
<span class="profile">Tava bilde: </span>
<input id="picture" name="picture" class="with-label" style="width: 270px;" type="file" placeholder="Tava bilde" />
<label>*</label>
</div>
<input type="submit" id="submit" value="Labot Profilu" name="edit" class="fix-this" />
</form>
After I select either no picture, or if I select a picture, it gives me var_dump with detials –
array
'upload_data' =>
array
'file_name' => string '' (length=0)
'file_type' => string '' (length=0)
'file_path' => string './images/pictures/' (length=18)
'full_path' => string './images/pictures/' (length=18)
'raw_name' => string '' (length=0)
'orig_name' => string '' (length=0)
'client_name' => string '' (length=0)
'file_ext' => string '' (length=0)
'file_size' => string '' (length=0)
'is_image' => boolean false
'image_width' => string '' (length=0)
'image_height' => string '' (length=0)
'image_type' => string '' (length=0)
'image_size_str' => string '' (length=0)
What could be the problem?
$config['upload_path'] = './images/pictures/';be sure that the path you write is correct and it has the proper 777 right to write the file into.Also, as Kristian wrote, you are are doing the
$this->upload->do_upload();upload part twice.To check for errors, you can do this: