08-04-2012 11:37 PM
[SOLVE] codeigniter: uploading file | Edited by
letsmove 10-04-2012 06:44 PM
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
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
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
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
09-04-2012 02:19 AM
RE:
[SOLVE] codeigniter: uploading file
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::..
10-04-2012 04:14 PM
RE:
[SOLVE] codeigniter: uploading file | Edited by
letsmove 10-04-2012 04:15 PM
letsmove Murid Akademi II
Posts: 39
Joined: 13.07.09
udah tapi belum bisa juga masih error.
Code chmod -vR 777 docclassifier/upload
oh iya lupa kasih info os nya. saya menggunakan ubuntu 10.10
i dont wanna move slow
10-04-2012 06:43 PM
RE:
[SOLVE] codeigniter: uploading file
letsmove Murid Akademi II
Posts: 39
Joined: 13.07.09
yes, udah ketemu masalahnya masta, ternyata pas dibagian ini:
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
Code $this->upload->initialize($config);
jadinya :
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
Jump to Forum:
Peraturan Forum
Pengumuman
Absen Member baru
Bingung??? disini ajah...
Kritik & Saran
C/C++
Java
PHP
Visual Basic
Out Of Topic Programing
Windows
Networking
Mac & Apple Family
Open Source OS
Mobile Phone OS
Explore CMS PHP-Fusion
Post Your PHP-Fusion Site Here.
Info Security
Black & White Proof of Concept
E-Book
MP3 Album
Video
Software
Manga / Comic
Share Proof of Concept Your Design
Out Of Topic
Info Seminar, Event, Pameran, Etc
Can't Speak Indonesian? Post Here
Share Pengetahuan Umum