Uploadify? ??? ?? jQuery ???????. ?? ??? ??? ?? ????? ????.
Uploadify ???? ??????? git ????? ???? ???? ?? ?? ????. ???? ???? ??
https?? ??? ????. //github.com/xjflyttp/yii2-uploadify-widget?? ???????? ??? ?? ??? ????. (?? ??: yii ????)
① ???.json? ????(? ???? ?? ????? ??) require? ?? ?? uploadify? ?????
"require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.6", "yiisoft/yii2-bootstrap": "*", "yiisoft/yii2-swiftmailer": "*", "xj/yii2-uploadify-widget": "~2.0.0" //這里是新添加的 },
② ???? ???? yii2-uploadify-widget? ??? ? ???, ? ???? ?? ?????? ???? ???? ?? ??? ?? ????? ?????.
③ ? ??
<?php use yii\web\JsExpression; //外部TAG echo Html::fileInput('test', NULL, ['id' => 'test']); echo Uploadify::widget([ 'url' => yii\helpers\Url::to(['s-upload']), 'id' => 'test', //需要跟上fileInput 的id 對應(yīng) 'csrf' => true, 'renderTag' => false, 'jsOptions' => [ 'width' => 100, 'height' => 40, 'onUploadError' => new JsExpression(<<<EOF function(file, errorCode, errorMsg, errorString) { console.log('The file ' + file.name + ' could not be uploaded: ' + errorString + errorCode + errorMsg); } EOF ), 'onUploadSuccess' => new JsExpression(<<<EOF function(file, data, response) { data = JSON.parse(data); if (data.error) { console.log(data.msg); } else { //在此處理你的圖片 console.log(data.fileUrl); } } EOF
④ ???? ??? ??
<?php namespace \backend\controllers; use xj\uploadify\UploadAction; class TestController extends \yii\web\Controller { public function actions() { return [ 's-upload' => [ 'class' => UploadAction::className(), //磁盤目錄 'basePath' => '@webroot/upload', //訪問目錄 'baseUrl' => '@web/upload', //防止跨站攻擊 'enableCsrf' => true, // default 'postFieldName' => 'Filedata', // default //BEGIN METHOD 'format' => [$this, 'methodName'], //END METHOD //BEGIN CLOSURE BY-HASH //是否覆蓋相同文件 'overwriteIfExist' => true, //創(chuàng)建圖片名稱 'format' => function (UploadAction $action) { $fileext = $action->uploadfile->getExtension(); $filename = sha1_file($action->uploadfile->tempName); return "{$filename}.{$fileext}"; }, //想要多調(diào)用這個函數(shù) 'format' => function (UploadAction $action) { $fileext = $action->uploadfile->getExtension(); $filehash = sha1(uniqid() . time()); $p1 = substr($filehash, 0, 2); $p2 = substr($filehash, 2, 2); return "{$p1}/{$p2}/{$filehash}.{$fileext}"; }, */ 'validateOptions' => [ 'extensions' => ['jpg', 'png'], //后綴驗證 'maxSize' => 1 * 1024 * 1024, //上傳大小限制 ], //驗證前處理 'beforeValidate' => function (UploadAction $action) { //throw new Exception('test error'); }, //驗證后處理 'afterValidate' => function (UploadAction $action) {}, //保存前處理 'beforeSave' => function (UploadAction $action) {}, //保存后處理 'afterSave' => function (UploadAction $action) { //$action->output 返回給瀏覽器的數(shù)據(jù) //返回Url 圖片返回的路徑 //$action->getWebUrl() //圖片的名稱 //$action->getFilename(); //保存圖片的物理位置 //$action->getSavePath(); //輸出 //$action->output['fileUrl'] = $action->getWebUrl(); //$action->output['fileName'] = $action->getFilename(); //$action->output['filePath'] = $action->getSavePath(); //$action->getFilename(); // "image/yyyymmddtimerand.jpg" //$action->getWebUrl(); // "baseUrl + filename, /upload/image/yyyymmddtimerand.jpg" //$action->getSavePath(); // "/var/www/htdocs/upload/image/yyyymmddtimerand.jpg" $action->output[‘fileUrl’] = $action->getWebUrl() }, ], ]; } } ?>
? ??? yii2?? ???? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

yiiassetbundlesorganizeangeangeangeangeangeanagewebassetslikecss, javaScript, andimagesinayiiApplication.1

MVC ??? ???? ?? ????? ????? ?? ???? ?????? ??? ?? ??? ?????. ????? ?? ??? ???? ??? ????? ??? ??? ??? ????? ??? ???? ????. 1.?? ??? ???? ???? ?????? ??????. ?? ??, ???? Postscontroller? ?? ?? ?????? ??? Views/Posts/show.html.erb ?? views/posts/show.cshtml??????. 2. ?? ? ???? ???? ?? ? view ( 'posts.custom_template')?? Render'Custom_template '? ?? ??? ???? ??????.

TO TOREABASICROUTEINYII, FIRSTEPACONTROLLERBYPLACINGITINTECONTROLLERSDIRECTORYWITHPROPENAMINAMINAMINAMINAMINAMINATDEFINITIONEPTENDENDINGYII \ WEB \ CONTROLLER.1) CREATEANCACTIONSTATRINGWITH "ACTION"

Ayiideveloper'skeyErsponsibilitiesIngindingandimplementingFeatures, ApplicationSecurity, ? ??? ? ??? ???? QualificationSneedeDareastronggraspofpp, Experience-EndTechnologies, DatabasemanagementsKills ? Problem-Solvingabi

YII?? ??? ?? ??? ???? ??? ????? ???? ???? ???? ???? ???? ????? ?? ??? ???? ????. ?? ?? ??? ?? ???? ????? ?? ?????? JSON? ??????. ????? ??? ??? ?? ??? ?????. ?? ???? ??? ?????. 1. ???? ???? ????. 2. ??? ????? ??????. 3. URL ?? ????? ? ????. 4. ?? ??, ??? ?? ??, ???? ?? ?? ???? ???; 5. AccessControl ?? ?? ?? ??? ???? ???? ??????. ?? ??, ActionProfile ($ id)? /site /profile? id = 123? ?? ????? ??? ??? ???? ??? ? ? ????. ?? ??????

ayiidevelopercraftswebapplicationsingtheyiiiframework, ?? ?? Killsinphp, yii-specificknowledge ? webdevelopmentlifecyclemanagement.keySponsibilitiesInclude : 1) WritingEfficientCodetOptimizeperFormance, 2) poploitizingsecurityTopectAppplications,

touseactivercordinyifeffectively, ??? ??? ??? createamodelclassforeachtableandinteractwiththeabaseusingobject-orientedmethods.first, defineamodelclasseptendingyii \ db \ activerecordandspecorrecorrespecorrespectecorrespectedtablenaMeAblename ()

?? ??? ????, ?? ??? ??? ?????, ?????? ??? ????, ??? ??? ???? ????? YII?? ?? ???? ?? ? ? ????. ?? ??? ??? ????. 1. filetarget ?? dbtarget? ?? ?? ???? ?? ?? ??? ???? ??? '??'?? ?????. 2. yii :: info () ?? yii :: ?? ()? ???? ??? ???? ??? ????? (? : ??? ?? ? ???? ???)? ??? ?; 3. ????? ?? ? ??? ?? ??????? ??? ???? ?? ???? ???? ?? ??? ?? ??? ???????. 4. ???? ??? ?? ? ? ?? ?? ??? ?? ??? ???? ???? ??? ???? ??? ???? IP ? ??? ??? ?? ? ? ????. 5
