Welcome Guest, Not a member yet? Register   Sign In
File upload wont work
#1

Hi,

i want to use the file upload, i looks like's its uploaded but no file found, file permissions are the right one.

PHP Code:
function upload() {
        
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
        
header("Cache-Control: post-check=0, pre-check=0"false);
        
header("Pragma: no-cache");

        
$config['upload_path'] = '/var/www/images';

        
$config['allowed_type'] = "JPG|PNG";

        
$config['max_size'] = "256000";

        
$config['max_width'] = '5000';

        
$config['max_height'] = '5000';
        
        
$this->load->library('upload'$config);
        
$SelectedFile 'SelectedFile';
        
$this->upload->initialize($config);
        if (
$this->upload->do_upload("SelectedFile")) {
// $error = array('error' => $this->upload->display_errors());
             
echo json_encode(array('message' => 'fout',
                
'error_message' => $this->upload->display_errors(''''),
                
'post' => $_FILES));

        } else {
                             
//$imgdata = array('upload_data' => $this->upload->data());
                
$imgdata['upload_data'] = $this->upload->data();
            
      
            
            echo 
json_encode(array('message' => 'ok''upload_data' => $this->upload->data()));
        
            
            
        } 

i have tried through the normal form and also through an ajax upload, can anybody tell me what i'm doing wrong?

Kind regards,

David
Reply
#2

Check your else statement. You're saying if the upload fails it's ok. If the upload fails you should be checking $this->upload->display_errors()
Reply
#3

(06-22-2015, 10:42 AM)CroNiX Wrote: Check your else statement. You're saying if the upload fails it's ok. If the upload fails you should be checking $this->upload->display_errors()

even if i change this statement the if will give an message that the filetype not has been set.
Reply
#4

i made a big typo:

$config['allowed_type'] = 'jpg|png|gif';

it need to be:

$config['allowed_types'] = 'jpg|png|gif';

Topic maybe closed.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB