Uploadify graph Upload efficiency based on thinkphp

Source: Internet
Author: User
PhpAction server based on thinkphp's uploadify image upload function & lt ;? Php * & nbsp; * Tochangethistemplate, chooseTools | Templates & nbsp; * andopenthetemplateintheeditor. & nbsp; *** & nbsp; * Descript uploads graphs based on thinkphp's uploadify function

Php Action server



/*
* To change this template, choose Tools | Templates
* And open the template in the editor.
*/


/**
* Description of UploadAction
*
* @ Author hxwj
*/
Class UploadAction extends CommonAction {
Public function _ initialize (){
// Reset the SESSION to solve the http 302 error of Uploadify under Firefox.
$ Session_name = session_name ();
If (isset ($ _ POST [$ session_name]) {
Session_id ($ _ POST [$ session_name]);
Session_start ();
}
}
Public function upload (){
Import ("ORG. Net. UploadFile ");
// Import Upload class
If ($ _ FILES ){
$ Upload = new UploadFile ();
// Set the size of the uploaded file
$ Upload-> maxSize = 204800;
// Set the Upload file type
$ Upload-> allowExts = array ('jpg ', 'GIF', 'PNG', 'jpeg ');
// Set the attachment Upload Directory
$ Upload-> thumb = true;
$ Upload-> thumbPrefix ='m _ '; // produce two thumbnails.
// Set the maximum width of the thumbnail.
$ Upload-> thumbMaxWidth = '000000 ';
// Set the maximum height of the thumbnail.
$ Upload-> thumbMaxHeight = '000000 ';
$ Upload-> savePath = './Uploads/shunongjj /';
// Set the thumbnail to be generated, which is only valid for image files


// Set the path of the referenced image library package
// Delete the source image
// $ Upload-> thumbRemoveOrigin = true;
If (! $ Upload-> upload ()){
// Capture Upload exceptions
// $ This-> error ($ upload-> getErrorMsg ());
$ Data ['status'] = '0 ';
$ This-> ajaxReturn ($ data, 'json ');
} Else {
// Obtain the information of the successfully uploaded File
$ Info = $ upload-> getUploadFileInfo ();
$ Imgpath = '/Uploads/shunongjj/'. $ info [0] ['savename'];
$ Data ['picurl'] = $ imgpath;
$ Data ['status'] = '20140901 ';
$ This-> ajaxReturn ($ data, 'json ');
}
}
}
/*
* No thumbnail
*/
Public function upload_wsl (){
Import ("ORG. Net. UploadFile ");
// Import Upload class
If ($ _ FILES ){
$ Upload = new UploadFile ();
// Set the size of the uploaded file
$ Upload-> maxSize = 204800;
// Set the Upload file type
$ Upload-> allowExts = array ('jpg ', 'GIF', 'PNG', 'jpeg ');
// Set the attachment Upload Directory
$ Upload-> savePath = './Uploads/shunongjj /';
// Set the thumbnail to be generated, which is only valid for image files


// Set the path of the referenced image library package
// Delete the source image
// $ Upload-> thumbRemoveOrigin = true;
If (! $ Upload-> upload ()){
// Capture Upload exceptions
// $ This-> error ($ upload-> getErrorMsg ());
$ Data ['status'] = '0 ';
Return false;
// $ This-> ajaxReturn ("", "Upload failed ","");
} Else {
// Obtain the information of the successfully uploaded File
$ Info = $ upload-> getUploadFileInfo ();
Return $ imgpath = '/Uploads/shunongjj/'. $ info [0] ['savename'];
}
}
}
/*
* Company rotation homepage image
*/
Public function upload_index (){
Import ("ORG. Net. UploadFile ");
// Import Upload class
If ($ _ FILES ){
$ Upload = new UploadFile ();
// Set the size of the uploaded file
$ Upload-> maxSize = 204800;
// Set the Upload file type
$ Upload-> allowExts = array ('jpg ', 'GIF', 'PNG', 'jpeg ');
// Set the attachment Upload Directory
$ Upload-> savePath = './Uploads/shunongjj /';
// Set the thumbnail to be generated, which is only valid for image files


// Set the path of the referenced image library package
// Delete the source image
// $ Upload-> thumbRemoveOrigin = true;
If (! $ Upload-> upload ()){
// Capture Upload exceptions
// $ This-> error ($ upload-> getErrorMsg ());
$ Data ['status'] = '0 ';
$ This-> ajaxReturn ($ data, 'json ');
} Else {
// Obtain the information of the successfully uploaded File
$ Info = $ upload-> getUploadFileInfo ();
$ Imgpath = '/Uploads/shunongjj/'. $ info [0] ['savename'];
$ Data ['picurl'] = $ imgpath;
$ Data ['status'] = '20140901 ';
$ This-> ajaxReturn ($ data, 'json ');
}
}
}
}


?>



Template tpl end

Html

(Image Upload specification: 176*107)


Js

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.