dedecms織夢(mèng)圖集上傳圖片默認(rèn)是要手動(dòng)填寫注釋的,有時(shí)我們做好了產(chǎn)品圖和圖片名稱,為了方便想讓上傳圖片后自動(dòng)獲取圖片名做注釋,那下面的教程就非常有用了。
1、打開 dedeswfupload.php 找到(注意,dede為默認(rèn)后臺(tái)的目錄,請(qǐng)自行登錄自己所在后臺(tái)目錄修改)
echo "FILEID:".$_SESSION['fileid'];
在它的上面加入
$file_snames = explode('.', $Filename);
$file_filename = $file_snames[count($file_snames)-2];
$_SESSION['file_filename'][$_SESSION['fileid']] = $file_filename;
繼續(xù)找到
/************************ //刪除指定ID的圖片 *************************/
在它的上面加入
/************************
//生成注釋
function GetThumbnail(){ }
*************************/
else if($dopost=='thumbalt')
{
if( empty($id) )
{
header('HTTP/1.1 500 Internal Server Error');
echo 'No ID';
exit(0);
}
if (!is_array($_SESSION['file_filename']) || !isset($_SESSION['file_filename'][$id]))
{
header('HTTP/1.1 404 Not found');
exit(0);
}
if($cfg_soft_lang=='utf-8') $file_filename = $_SESSION['file_filename'][$id];
else $file_filename = iconv( 'UTF-8', 'gb2312//IGNORE' , $_SESSION['file_filename'][$id]);
echo $file_filename;
exit(0);
}
|
2、打開 dedealbum_add.php 找到
$imginfo = !empty(${'picinfook'.$k}) ? ${'picinfook'.$k} : '';
改成
$imginfo = !empty(${'picinfook'.$k}) ? ${'picinfook'.$k} : $_SESSION['file_filename'][$k];
3、打開 dedealbum_edit.php 找到
$imginfo = !empty(${'picinfook'.$k}) ? ${'picinfook'.$k} : '';
改成
$imginfo = !empty(${'picinfook'.$k}) ? ${'picinfook'.$k} : $_SESSION['file_filename'][$k];
4、打開 dedejshandlers.js 找到
newImgDiv.innerHTML += '<div >注釋:<input type="text" name="picinfo'+albImg+'" value="" /></div>';
改成
查看源碼打印代碼幫助
newImgDiv.innerHTML += '<div >注釋:<input type="text" name="picinfo'+albImg+'" value="" id="picinput'+albImg+'" /><span id="picinfo'+albImg+'" ></span></div>';
var picinfo = document.getElementById('picinfo'+albImg);
var picinput = document.getElementById('picinput'+albImg);
var myajax = new DedeAjax(picinfo,false,false,"","","");
myajax.SendGet2('swfupload.php?dopost=thumbalt&id='+pid);
picinput.value = picinfo.innerHTML;
DedeXHTTP = null;
完成