CodeIgniter Forums
CI 3 + Dropzone - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: CI 3 + Dropzone (/thread-72598.html)



CI 3 + Dropzone - Camp1 - 01-10-2019

I'm trying to create an image upload with Dropzone, every time I attach an image, I get POST 200 and I think everything is fine but the image has not been uploaded.

I can not make it work, can someone help me?

Thanks!!!!



Controller:

Code:
 public function test(){

        $config['upload_path']   = './uploads/';

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

        $config['max_size']      = 1024;


        $this->load->library('upload', $config);

        $this->upload->do_upload('file');
}

View:
Code:
    <link href='https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.4.0/dropzone.css' type='text/css' rel='stylesheet'>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.4.0/dropzone.js' type='text/javascript'></script>
   
    <script>
    Dropzone.options.fileupload = {
      acceptedFiles: 'image/*',
      url: '<?= base_url('admin/galeria/test') ?>',
      maxFilesize: 2
    };
    </script>

       <?php echo form_open_multipart('admin/galeria/test', array('class' => 'dropzone', 'id' => 'fileupload')) ; ?>
      </form>



RE: CI 3 + Dropzone - alexmocanu - 01-11-2019

You should be doing some basic error checking on the server too. Dropzone just grabs the file and sends it to the server. What happens after that is no longer it's concern. 




Replace this: 
PHP Code:
$this->upload->do_upload('file'

With something like this and see what error is being reported.
PHP Code:
       if ( ! $this->upload->do_upload('file'))
 
       {
 
           //handle errors
 
           echo  $this->upload->display_errors();
 
       } else {
 
           //success, do something with the result!
 
           print_r($this->upload->data());
 
       



RE: CI 3 + Dropzone - php_rocs - 01-11-2019

@Camp1,

Are you receiving any error messages on the CI side? CI log? Does the upload directory have the right permissions set?