내용중 이미지 삭제 > PHP

STUDY ROOM

PHP

내용중 이미지 삭제

페이지 정보

작성자 JMStudy 작성일15-07-10 11:57 조회8,094회 댓글0건

본문

본문 내용중 에디터로 이미지를 올린경우 추출해서 삭제

 

 

$sql = "select * from write_gallery";

$res = mysql_query($sql);

 

while($row = mysql_fetch_array($res)){

 

echo $row[wr_id]."<br>";

 

$cnt = preg_match_all('@<img\s[^>]*src\s*=\s*(["\'])?([^\s>]+?)\1@i',$row[wr_content],$output); 

$cols = array();

for($i = 0; $i < $cnt; $i ++) {

$cols[$j][] = str_replace('""', '"', ($output[2][$i] != '') ? $output[2][$i] : $output[4][$i]);

 

if($output[6][$i] != '')

$j ++;

 

$arr_img = explode("/",$cols[$j][$i]);

$img = $arr_img[count($arr_img)-1];

//echo $img."<br>";

//echo $cols[$j][$i]."<br>";

 

@unlink("./editor/uploaded/img/$img");

}

 

댓글목록

등록된 댓글이 없습니다.