Chủ Nhật, 7 tháng 9, 2025

Function lấy hình ảnh

### Images 

get__category_image($images)

### No-Images 

get__category_image()

function get__category_image($img=""){

    return  "

    <input type='file' name='userfile'><br> 

    <input type='hidden' name='images' value='".$img."'> 

    ".($img?"Delete: <input type='checkbox' value='1' name='delimg'><br>":"")."

    ".($img?"<img src='".INCLUDE_PATH."uploads/shop/pic/".$img."' style='height:110px;padding-top:10px;'>":"")."

     ";

    return "";    

    $content = "<select name=\"catimage\">";

    $path1 = explode ("/", "../uploads/shop/category/");

    $path = "$path1[0]/$path1[1]/$path1[2]/$path1[3]";

    $handle=opendir($path);

    while ($file = readdir($handle)){

        if ( (preg_match("/^([_0-9a-zA-Z]+)([.]{1})([_0-9a-zA-Z]{3})$/i",$file)) AND $file != "AllTopics.gif") {    

            $tlist .= "$file ";

        }

    }

    closedir($handle);

    $tlist = explode(" ", $tlist);

    sort($tlist);

    for ($i=0; $i < sizeof($tlist); $i++) {

        if($tlist[$i]!="") {

            if ($img == $tlist[$i]) {

                $sel = "selected";

            } else {

                $sel = "";

            }

            $content .= "<option name=\"catimage\" value=\"$tlist[$i]\" $sel>$tlist[$i]\n";

        }

    }

    $content.="</select>";

    return $content;   

}

Không có nhận xét nào:

Đăng nhận xét