function uploadImg() { $supportFileTypes = array('jpg', 'gif', 'png', 'jpeg', 'apk'); $publicPath = "/public/uploads/imgs"; $upload = new \Think\Upload(); // 实例化上传类 $upload->maxSize = 3145728; // 设置附件上传大小 $upload->exts = $supportFileTypes; // 设置附件上传类型 $upload->rootPath = $_SERVER['DOCUMENT_ROOT'] . $publicPath; $upload->savePath = "/" . session('commentid') . "/"; // 设置附件上传(子)目录 // 上传文件 $info = $upload->upload(); if (!$info) { // 上传错误提示错误信息 $ret['result'] = false; $ret['err'] = $upload->getError(); } else { // 上传成功 获取上传文件信息 $picDir = ""; foreach ($info as $file) { $picDir .= $publicPath . $file['savepath']; $abdir = $_SERVER['DOCUMENT_ROOT'] . $picDir; $abtdir = $abdir . "thumb/" . $file['savename']; $abdir .= $file['savename']; thumb_img($abdir, 400, $abtdir, true); $picDir .= "thumb/" . $file['savename']; $picDir .= ";"; } $ret['result'] = true; $ret['picDir'] = $picDir; } return $ret; }
while (have_posts()) { the_post(); ?> <li> <a href="<?php the_permalink(); ?> "> <span class="port-zoom">+</span> <p class="port-title"><?php the_title(); ?> </p> <div class="port-bgfade"></div> <?php thumb_img($post->ID, '600', '409', '100', get_the_title()); ?> </a> </li> <?php } } else { ?> <p class="error">No results found.</p> <?php } ?> <!-- Start Pagination - WP-PageNavi -->
?> </li> <li class="comment"><?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'comments-link', ''); ?> </li> <li class="tag"><?php the_tags('', '-', ''); ?> </li> </ul> <div class="blog-img"> <?php thumb_img($post->ID, '940', '390', '100', get_the_title()); ?> </div> <div class="shadow-big"></div> <p><?php echo substr(get_the_excerpt(), 0, strrpos(substr(get_the_excerpt(), 0, 990), ' ')) . ' ...'; ?> </p> <a href="<?php the_permalink(); ?> "><button class="greybutton">read more</button></a> <div class="lines"></div>