久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      yii實現(xiàn)圖片上傳

      yii實現(xiàn)圖片上傳

      具體代碼如下:

      (推薦教程:yii)

      1、model

      <?php namespace frontendmodels;   use yiibaseModel; use yiiwebUploadedFile; use yiidbActiveRecord; use yiidbQuery;   class UploadForm extends ActiveRecord {     /**      * @var UploadedFile      */     public $t_img;     public $t_title;     public $t_content;     public function rules()     {         return [             [['t_img'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg,bmp,jpeg'],         ];     }     public function attributeLabels()     {         return [             't_img'=>'請上傳文章圖片',             'verifyCode' => '請在右面輸入驗證碼',         ];     }         public function upload()     {         $imgName=time().rand(100,999).".".$this->t_img->extension;         if ($this->validate()) {             $this->t_img->saveAs('uploads/' .$imgName);             $path='uploads/' .$imgName;             return $path;         } else {             return false;         }     } }   ?>

      2、控制器

       $data=Yii::$app->request->post();             $data['t_addtime']=date('Y-m-d H:i:s');             $upload->t_img = UploadedFile::getInstance($upload, 't_img');             $path=$upload->upload();

      3、視圖層

      <?php use yiiwidgetsActiveForm; use yiihelpersHtml; use yiihelpersUrl; ?> <?=Html::a('返回','?r=course/classspace&c_id='.$c_id)?> <?php $form=ActiveForm::begin(     [         'options' => ['enctype' => 'multipart/form-data'],         'method'=>'POST',     ] );?> <table class="table">       <tr>         <td>               <input type="text" placeholder="請?zhí)顚懺掝}標題" name="t_title" id="t_title" value=<?=$coursedraft['d_title']?>   >         </td>         </tr>     <tr>         <td>             <textarea name="t_content" id="t_content" cols="30" rows="10" placeholder="請?zhí)顚懺掝}內(nèi)容"><?=$coursedraft['d_content']?></textarea>         </td>     </tr>     <tr>         <td>            <?=$form->field($upload,'t_img')->fileInput()?>         </td>     </tr>     <tr>         <div class="btn-group">             <td>                 <?=Html::submitButton('提交話題',['class'=>'btn btn-success'])?>             </td>         </div>       </tr> </table> <?php ActiveForm::end();?> <input type="hidden" value=<?=$c_id?>  id="c_id" /> </body> <?php $js = <<<END     $(function(){ //        $(document).on('click','#caogao',function() { //            var title = $("#t_title").val(); //            var content = $("#t_content").val(); // //            $.ajax({ //                type: "POST", //                url: "?r=course/coursedraft", //                data: {t_title: title, t_content: content, d_id: d_id} //            }) //        })         function show(){             var title=$("#t_title").val();             var content=$("#t_content").val();             var c_id=$('#c_id').val();             $.ajax({                 type: "POST",                 url: "?r=course/coursedraft",                 data: {d_title:title,d_content:content,c_id:c_id,d_state:0}             });         }         setInterval(show,5000);     }) END; $this->registerJs($js); ?> </html>

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號