if (fckconfig.imageupload)
Dialog. AddTab (' Multiupload ', fcklang.dlgmultiupload);
if (Tabcode = = "Multiupload")//this tab tab page also has an album category to get
{
Dialog. Sizer.resizedialog (450,450);//Initialize the size of the pop-up box
$.getjson ('/picture/cate/get ', {},function (data) {//In other projects this is not necessary
if (data.items.length>0)
{
$ ("#multi_albumlist"). empty ();
$.each (Data.items,function (i,cate) {
var option = new option (CATE.CATE_NAME,CATE.CATE_ID);
$ ("#multi_albumlist"). Append (option);
});
}
Else
{
var option = new option (",");
$ ("#multi_albumlist"). Append (option);
}
$ ("#multi_albumlist"). Show ();
});
}
1.3 fckeditor/fckconfig.js File New pictures bulk upload URL
Fckconfig.imagemultiuploadurl = '/picture/upload/multisave ';
(2) Page layout settings
Fckeditor/editor/dialog/fck_image.html
<div id= "Divmultiupload" style= "Display:none" >
<form id= "Frmmultiupload" method= "Post target=" UploadWindow1 "enctype=" Multipart/form-data "action=" "onsubmit=" return Checkmultiupload (); " >
<input id= "TxtUploadFile1" style= "width:80%" type= "file" size= "a" name= "Multiphotofile0_f"/><br/>< br/>
<input id= "TxtUploadFile2" style= "width:80%" type= "file" size= "a" name= "Multiphotofile1_f"/><br/>< br/>
<input id= "TxtUploadFile3" style= "width:80%" type= "file" size= "a" name= "Multiphotofile2_f"/><br/>< br/>
<input id= "txtUploadFile4" style= "width:80%" type= "file" size= "a" name= "Multiphotofile3_f"/><br/>< br/>
<input id= "TxtUploadFile5" style= "width:80%" type= "file" size= "a" name= "Multiphotofile4_f"/><br/>< br/>
<input id= "TxtUploadFile6" style= "width:80%" type= "file" size= "a" name= "Multiphotofile5_f"/><br/>< br/>
<div>
<label style= ' line-height:20px; ' ><span style= ' line-height:20px; ' > Compression: </span><input type= ' checkbox ' name= ' multi_compress ' value= ' 1 ' checked= ' checked '
<label style= ' line-height:20px; ' ><span style= ' line-height:20px; ' > Add watermark: </span><input type= ' checkbox ' name= ' multi_water ' value= ' 1 ' checked= ' checked ' <br/>
Album: <select id= "multi_albumlist" style= ' display:none ' name= ' multi_cate_id ' ></select>
<a href= ' javascript:void (0) ' id= ' Multi_linkcreatealbum "onclick=" return Multi_checkalbum (); "> new album </a>
<input type= "text" id= "Multi_newalbuminput" name= "Multi_album_name" size= "ten" maxlength= "style= ' Display:none"; >
<button id= "Multi_btncreatealbum" style= ' display:none; ' onclick= ' return multi_createnewalbum (); "> Create </ button> <a href= "javascript:void (0)" id= "Multi_btncancelalbum" style= ' display:none; ' onclick= ' multi_ Cancelalbum () "> Cancel </a>
<input type= ' hidden ' name= ' multi_pic_f ' value= ' Goods_add '
</div>
<p><input id= "BtnUpload1" type= "submit" value= "Insert Picture"/></p>
<script type= "Text/javascript" >
document.write (' <iframe name= "UploadWindow1" style= "Display:none" src= "' + fcktools.getvoidurl () + '" ></ Iframe> ');
</script>
</form>
</div>
(3) JS Verification when submitting
function Checkmultiupload ()
{
var sFile1 = Gete (' TxtUploadFile1 '). Value;
var sFile2 = Gete (' TxtUploadFile2 '). Value;
var sFile3 = Gete (' TxtUploadFile3 '). Value;
var sFile4 = Gete (' txtUploadFile4 '). Value;
var sFile5 = Gete (' txtUploadFile5 '). Value;
var sFile6 = Gete (' TxtUploadFile6 '). Value;
if (sfile1.length = 0 && sfile2.length = 0 && sfile3.length = 0 && sfile6.length = 0 &&am P Sfile5.length = = 0 && sfile6.length = 0)
{
Alert (' Please upload at least one picture ');
return false;
}
if ((FCKConfig.ImageUploadAllowedExtensions.length > 0 &&!ouploadallowedextregex.test (sfile)) | |
(FCKConfig.ImageUploadDeniedExtensions.length > 0 && ouploaddeniedextregex.test (sfile)))
{
Onuploadcompleted (202);
return false;
} Show animation Window.parent.Throbber.Show (); Gete (' Divmultiupload '). style.display = ' None '; return true;
}
(4) Callback function
function Callback_multisubmit (status, errid,html) {
if (status==0)
{
Insert a picture directly into the editor
var oparenteditor=window.parent.innerdialogloaded (). FCK;
oparenteditor.inserthtml (HTML);
Dialog. Closedialog ();
Return
}
Switch (Errid)
{
Case 0:
Alert (' This picture has not been uploaded successfully, please upload it again. ');
Break
Case 1:
Alert (' This photo was not uploaded successfully, album space is not sufficient. ');
Break
Case 2:
Alert (' This photo you selected is over 2MB, please choose again. ');
Break
Case 3:
Alert (' Picture is not well-formed, you can upload photos in jpg, GIF, and PNG format. ');
Break
Default:alert (' This picture has not been uploaded successfully, please upload it again. ');
}
}
(5) After submitting the controller processing $img _url = Array ();
$img _title = Array ();
for ($i =0; $i < $count; $i + +)
{
$file _name = "Multiphotofile". $i. " _f ";
if (!empty ($_files [$file _name]["Tmp_name"])
{
$file = new Henu_uploadfile ('/temp/', $_files [$file _name] ["Tmp_name"], $_files [$file _name] ["name"], $_files [$file _n AME] ["size"], $_files [$file _name] ["type"]);
$check _res = $file->check ();
if ($check _res!== true)
{
Error
if ($check _res = = 1)
{
echo "<script>parent.callback_multisubmit (1,2);</script>";
}
ElseIf ($check _res = 2)
{
echo "<script>parent.callback_multisubmit (1,3);</script>";
}
Return
}
$img _info = $file->upsend (); Return upload file information
if ($img _info = = False)
{
Error
echo "<script>parent.callback_submit (1,0);</script>";
Return
}
$title = $img _info ["Oldname"];
$filetype = $img _info ["filetype"];
Switch ($filetype)
{
Case "Image/jpg":
$filetype = "JPG";
Break
Case "Image/gif":
$filetype = "gif";
Break
Case "Image/png":
$filetype = "png";
Break
Default:
$filetype = "JPG";
}
If the product is uploaded, all processed into JPG
if ($pic _f = = "Goods_add")
{
$filetype = "JPG";
}
/**
* Call picture Upload
*/
$client->setconfig ("Upload", "index", "POST", Array ("store_id" => $store _id, "cate_id" => $cate _id, "File_type "=> $filetype," title "=> Htmlspecialchars ($title)," Water "=> $water," compress "=> $compress," IP "=> Ip2long (Real_ip ()), "Picture");
$http = $client->gethttp ();
$http->setfileupload ($img _info ["Picturetruepath"], ' img ');
$res = $client->getdata ();
if (Isset ($res ["RSP"] ["IMG"])
{
/**
* Image upload Successful
*/
@unlink ($img _info ["Picturetruepath"]);
if ($pic _f = = "Goods_add")//Product upload
{
$img _url[$i] = $res ["RSP"] [img] ["Picture_path"]. '.' . $res ["RSP"] ["IMG"] ["File_type"];
$img _title[$i] = $title;
}
Else
{
echo "<script>parent.callback_multisubmit (0,0);</script>";
}
}
Else
{
echo "<script>parent.callback_multisubmit (1,0);</script>";
}
}
}
for ($i =0; $i <= $count; $i + +)
{
if (!empty ($img _url[$i]))
{
$callback _temp = "<img src= ' $img _url[$i] ' alt= ' $img _title[$i] '/><br/> ';
$callback _html. = $callback _temp;
}
}
Echo ' <script>parent.callback_multisubmit (0,0, "'. $callback _html. ' ");</script> ';
} |