mw tanya nih gan… saya mw upload file gambar di yii tp tidak menggunakan widget bawaan yii… sya pke script php standar dan sya letakkan scriptnya di controller sebelum $model->save(). kurang lebih script saya seperti ini gan :
[b]public function actionCreate()
{
$model=new Jemaat;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Jemaat']))
{
//var_dump($_FILES);exit();
$model->attributes=$_POST['Jemaat'];
$name=$_FILES['Jemaat']["name"]["image"];
$tmp_name=$_FILES['Jemaat']["tmp_name"]["image"];
//var_dump($tmp_name);exit;
if (isset($name)) {
if (!empty($name)) {
$location='/assets/uploads/';
//var_dump($location);exit();
if (move_uploaded_file($tmp_name, $location.$name)){
echo "File berhasil di upload";
$this->redirect('/jemaat/admin');
}
}else{
echo "Pilih Gambar dulu coyyy";
$this->render('create',array(
'model'=>$model,
));
}
}[/b]
tapi setelah saya jalankan muncul error kyak gini :
[b]PHP warning
move_uploaded_file(/assets/uploads/wallpaper_virtual_rails.jpg): failed to open stream: No such file or directory
D:\PROJECT\GbtSulim\protected\controllers\JemaatController.php(85)
73 $model->attributes=$_POST[‘Jemaat’];
74
75 $name=$_FILES[‘Jemaat’][“name”][“image”];
76
77 $tmp_name=$_FILES[‘Jemaat’][“tmp_name”][“image”];
78 //var_dump($tmp_name);exit;
79 if (isset($name)) {
80
81 if (!empty($name)) {
82
83 $location=’/assets/uploads/’;
84 //var_dump($location);exit();
85 if (move_uploaded_file($tmp_name, $location.$name)){
86 echo "File berhasil di upload";
87 $this->redirect(’/jemaat/admin’);
88 }
89
90 }else{
91 echo "Pilih Gambar dulu coyyy";
92 $this->render(‘create’,array(
93 ‘model’=>$model,
94 ));
95 }
96 }[/b]
kira" letak kesalahan dan solusinya gimna yah… mohon bantuannya…
nb : sya sdh buat folder uploads di sulim/assets/uploads. (sulim itu nama theme saya)