Username Password

Lost Password
View Thread
Explore Your Brain » Pemrograman » PHP
[SOLVE] codeigniter: uploading file
Username
Password
Register FAQ Members List Today's Posts Search

Print Thread

08-04-2012 11:37 PM [SOLVE] codeigniter: uploading file | Edited by letsmove 10-04-2012 06:44 PM
User Avatar

letsmove
Murid Akademi II


Posts: 39
Joined: 13.07.09
masta masta, mohon bantuannya ya. saya sedang belajar upload file menggunakan codeigniter

error yang saya dapatkan adalah seperti ini:

"The upload path does not appear to be valid."

dan inilah script asli yang ada di dokumentasi codeigniter

letak: view/upload_form.php

Download source  Code
<html>
<head>
<title>Upload Form</title>
</head>
<body>

<?php echo $error;?>

<?php echo form_open_multipart('upload/do_upload');?>

<input type="file" name="userfile" size="20" />

<br /><br />

<input type="submit" value="upload" />

</form>

</body>
</html>





Letak : view/upload_success.php

Download source  Code
<html>
<head>
<title>Upload Form</title>
</head>
<body>

<h3>Your file was successfully uploaded!</h3>

<ul>
<?php foreach ($upload_data as $item => $value):?>
<li><?php echo $item;?>: <?php echo $value;?></li>
<?php endforeach; ?>
</ul>

<p><?php echo anchor('upload', 'Upload Another File!'); ?></p>

</body>
</html>




dan ini controllernya: controller/upload.php

Download source  Code
<?php

class Upload extends CI_Controller {

   function __construct()
   {
      parent::__construct();
      $this->load->helper(array('form', 'url'));
   }

   function index()
   {
      $this->load->view('upload/upload_form', array('error' => ' ' ));
   }

   function do_upload()
   {
      $config['upload_path'] = './uploads/';
      $config['allowed_types'] = 'gif|jpg|png';
      $config['max_size']   = '100';
      $config['max_width']  = '1024';
      $config['max_height']  = '768';

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

      if ( ! $this->upload->do_upload())
      {
         $error = array('error' => $this->upload->display_errors());

         $this->load->view('upload/upload_form', $error);
      }
      else
      {
         $data = array('upload_data' => $this->upload->data());

         $this->load->view('upload/upload_success', $data);
      }
   }
}
?>





dan untuk struktur kode yang saya buat adalah seperti berikut

+application
+css
+image
+system
+uploads

:?plz? :hlp
i dont wanna move slow
 
Offline
09-04-2012 02:19 AM RE: [SOLVE] codeigniter: uploading file
User Avatar

EVA-00
HackAge


Posts: 2770
Joined: 21.05.08
Location: Wallahu a'lam
Age: 38
Hak akses direktori /upload & sub foldernya udah di set 777 blm?
Nabi Muhammad SAW bersabda :ā€¯ Barangsiapa Yang Mengamalkan Ilmu Yang Ia Ketahui Maka Allah Akan Memberikan Kepadanya Ilmu Yang Belum Ia Ketahuiā€¯ (HR. Imam Ahmad).

..::shn6 u!vJq Jnoh 3Joldx3 d33>I::..
 
Offline
10-04-2012 04:14 PM RE: [SOLVE] codeigniter: uploading file | Edited by letsmove 10-04-2012 04:15 PM
User Avatar

letsmove
Murid Akademi II


Posts: 39
Joined: 13.07.09
udah tapi belum bisa juga masih error.

Download source  Code
chmod -vR 777 docclassifier/upload





oh iya lupa kasih info os nya. saya menggunakan ubuntu 10.10
i dont wanna move slow
 
Offline
10-04-2012 06:43 PM RE: [SOLVE] codeigniter: uploading file
User Avatar

letsmove
Murid Akademi II


Posts: 39
Joined: 13.07.09
yes, udah ketemu masalahnya masta, ternyata pas dibagian ini:

Download source  Code
$config['upload_path'] = 'uploads';
      $config['allowed_types'] = 'gif|jpg|png';
      $config['max_size']   = '100';
      $config['max_width']  = '1024';
      $config['max_height']  = '768';

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




perlu ditambahkan code seperti ini

Download source  Code
$this->upload->initialize($config);




jadinya :

Download source  Code
<?php

class Upload extends CI_Controller {

   function __construct()
   {
      parent::__construct();
      $this->load->helper(array('form', 'url'));
   }

   function index()
   {
      $this->load->view('upload/upload_form', array('error' => ' ' ));
   }

   function do_upload()
   {
      $config['upload_path'] = 'uploads';
      $config['allowed_types'] = 'gif|jpg|png';
      $config['max_size']   = '100';
      $config['max_width']  = '1024';
      $config['max_height']  = '768';

      $this->load->library('upload', $config);
                $this->upload->initialize($config);
                                           
               
               
      if ( ! $this->upload->do_upload())
      {
                        $cek = var_dump(is_dir('./uploads'));
         $error = array('error' => $this->upload->display_errors());

         $this->load->view('upload/upload_form', $error,$cek);
      }
      else
      {
         $data = array('upload_data' => $this->upload->data());

         $this->load->view('upload/upload_success', $data);
      }
               
   }
}
?>





thanks to codeigniter forum.
i dont wanna move slow
 
Offline
Jump to Forum:
Forum powered by fusionBoard
Share this Thread
URL:
BBcode:
HTML:
Similar Threads
Thread Forum Replies Last Post
Php and MySQL jadi file installer(Exe) PHP 2 18-07-2014 14:15
Autorun or pnp at Framework CodeIgniter PHP 3 14-09-2013 11:59
[help] upload file to different server PHP 6 30-01-2013 14:13
Read This Before You Start File Sharing Pengumuman 1 08-12-2012 02:50
ASK : FTP (file transfer protocol) beda DOMAIN Out Of Topic 1 02-05-2012 12:37
Copyright © 2007-2016