: This article mainly introduces the batch upload of YiiUploadify. if you are interested in the PHP Tutorial, refer to it. Controller:
$ Reinfo = "fail ";
$ Filename = "";
// Important:
// When uploadify is used for upload, the sessionID changes each time,
// The negative effect after the change is that other session values under sessionID cannot be obtained. for example, the Yii: app ()-> session ['Ik '] value changes.
// However, the value of this field cannot be changed. the Yii: app ()-> session ['Ik '] value must be used for verification,
// Therefore, you must use this statement session_id ($ pse). it is used to change the sessionID back, which is consistent with the original sessionID to get the value smoothly.
// With this value, the original sessionID is consistent with the uploaded sessionID.
// Echo Yii: app ()-> session-> sessionID; this is the method for Yii to get sessionID
// W. one
$ Pse = Yii: app ()-> request-> getParam ('phpsession ');
Session_id ($ pse );
/*
* If you do not use the above sentence, Yii: app ()-> session ['Ik '] = $ who cannot be equal because sessionID has changed
*/
$ Who = (int) Yii: app ()-> request-> getParam ('who ');
$ Sjm = Yii: app ()-> request-> getParam ('sjm ');
$ Zlsjm = Yii: app ()-> request-> getParam ("zlsjm ");
// $ Xceikey = (int) Yii: app ()-> request-> getParam ('xceikey'); // Obtain the album ikey. select by default, the value is null. you must select a value.
If ($ who = Yii: app ()-> session ['Ik ']) {
$ Sjz = time ();
$ TempFile = $ _ FILES ['filedata'];
$ CheckType = pathinfo ($ tempFile ["name"], PATHINFO_EXTENSION );
If ($ checkType! = "Notimg "){
$ TargetPath = $ _ SERVER ['document _ root']. '/oa/upload/file /';
$ Scfile = date ("Y "). date ("m "). date ("d "). date ("His "). "_". $ who. "_". md5 (microtime ()). ". ". $ checkType;
$ TargetFile = str_replace ('//', '/', $ targetPath). $ scfile;
If (move_uploaded_file ($ tempFile ['tmp _ name'], $ targetFile )){
$ Relativeurl = "./upload/file/". $ scfile;
// $ Relativeurl = $ tempFile ["name"];
$ Zlfj = new Zlfj ();
$ Zlfj-> fj_zlsjm = $ zlsjm;
$ Zlfj-> fj_uikey = Yii: app ()-> session ["ik"];
$ Zlfj-> fj_path = "./upload/file/". $ scfile;
$ Zlfj-> fj_time = time ();
$ Zlfj-> fj_name = $ tempFile ["name"];
If ($ zlfj-> validate () & $ zlfj-> save ()){
$ Reinfo = $ relativeurl;
$ Filename = $ tempFile ["name"];
} Else {
@ Unlink ($ targetFile );
}
}
}
}
Echo CJSON: encode (array ("info" => "$ reinfo", "name" => $ filename ));
View: