Use the image class of discuz
// File domain name // processing method // new image if (! Empty ($ _ FILES ['Attach '] ['tmp _ name']) & is_uploaded_file ($ _ FILES ['Attach'] ['tmp _ name']) {$ query = DB: query ("select filename, filepath from pre_home_hall_pic where picid = $ picid"); while ($ value = DB: fetch ($ query )) {$ oldfilepath = $ value ['filepath']; $ filename = $ value ['filename'];} $ file_info = pathinfo ($ _ FILES ['Attach '] ['name']); $ ext = $ file_info ['extension']; // get the extension $ filepath = dirname ($ oldfilepath ).' /'. Date ('his '). strtolower (random (16 )). '. '. $ ext; // rename $ uploadpath = 'data/attachment/hall/'randomly /'. $ filepath; if (! Is_dir ('data/attachment/hall /'. $ oldfilepath) {unlink ('data/attachment/hall /'. $ oldfilepath); unlink ('data/attachment/hall/'.w.oldfilepath.'.thumb.jpg ');} $ res = move_uploaded_file ($ _ FILES ['Attach'] ['tmp _ name'], $ uploadpath); if ($ res) {require_once libfile ('class/image'); $ image = new image (); $ result = $ image-> Thumb ($ uploadpath, '', 140,140, 1);} $ data ['filename'] = $ _ FILES ['Attach '] ['name']; $ data ['filepath'] = $ filepath;} DB: update ('home _ hall_pic ', $ data, $ wherearr );