YiiUploadify batch Upload

Source: Internet
Author: User
: 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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.