public function actionSavecomment() { $transaction = Yii::app()->db->beginTransaction(); $time = time(); try { if ($_FILES['file-comment']['tmp_name']) { // echo "sukses"; $file_name = $_FILES['file-comment']['name']; $file_size = $_FILES['file-comment']['size']; $file_tmp = $_FILES['file-comment']['tmp_name']; $file_type = $_FILES['file-comment']['type']; if ($file_size <= 200000) { //200KB $hm = new ProjectCommentHead(); $hm->project_id = $_REQUEST['project_id']; $hm->project_views_id = $_REQUEST['views_id']; $hm->phase = $_REQUEST['phase_id']; $hm->description = "p"; $hm->datetime = date('Y-m-d H:i:s'); $hm->user_id = User::model()->findByPk(Yii::app()->user->id)->id; // $hm->type = $_REQUEST['type']; $hm->type = 1; if ($hm->save()) { // foreach($_FILES['file-comment']['tmp_name'] as $key => $tmp_name ){ // $file_name=$_FILES['file-comment']['name'][$key]; // $file_size=$_FILES['file-comment']['size'][$key]; // $file_tmp =$_FILES['file-comment']['tmp_name'][$key]; // $file_type=$_FILES['file-comment']['type'][$key]; // if ($file_size<20000){ $model = new ProjectComment(); $model->head_project_id = $hm->id; $model->name_file = $key . $time . $file_name; $model->comment_id = 999; $model->description = "nothing"; $model->confirmer = Yii::app()->user->id; $model->confirmed_date = date('Y-m-d H:i:s'); $model->project_views_id = $_REQUEST['views_id']; if ($model->save()) { if (move_uploaded_file($file_tmp, Yii::app()->basePath . "/../img/comment/{$key}{$time}{$file_name}")) { $transaction->commit(); echo "sukses"; } else { // echo "eror upload "; // echo "$file_tmp"; print_r($file_tmp); } } // } // else{ // $transaction->rollBack(); // echo "minimum image is 200KB"; // // echo "sukses"; // } // else // print_r($model->getErrors()); } else { print_r($model->getErrors()); } } else { echo "maximum image is 200KB"; } } // }else{ // echo "not sukses save head"; // } // $this->renderPartial('create_comment'); // } } catch (Exception $e) { $transaction->rollBack(); // other actions to perform on fail (redirect, alert, etc.) } }
<?php $model = ProjectComment::model()->findByPk($id); // $idh = ProjectComment::model()->findByPk($id)->head_project_id; $head = ProjectCommentHead::model()->findByPk($model->head_project_id); $project = Project::model()->findByPk($head->project_id); $project_name = Project::model()->findByPk(ProjectCommentHead::model()->findByPk($model->head_project_id)->project_id)->project_name; echo $idh; ?> <img class="img-close" src="<?php echo Yii::app()->request->baseUrl; ?> /img/close.png"> <center> <h1> DETAIL PROGRES IMAGE </h1> </center> <table> <tr> <td style="width:30%">Name </td> <td>:</td> <td style="width:70%"> <input maxlength="30" img_id="<?php echo $model->id; ?> " value="<?php echo $model->alias_name; ?> " type="text" id="input-edit-image"> <?php if ($model->alias_name == '') {