ecshop上传图片2
html代码
<tr> <td class="label">{$lang.lab_picture}</td> <td> <input type="file" name="goods_img" size="35" /> {if $goods.goods_img} <a href="goods.php?act=show_image&img_url={$goods.goods_img}" target="_blank"><img src="images/yes.gif" border="0" /></a> {else} <img src="images/no.gif" /> {/if} <br /><input type="text" size="40" value="{$lang.lab_picture_url}" style="color:#aaa;" onfocus="if (this.value == '{$lang.lab_picture_url}'){this.value='http://';this.style.color='#000';}" name="goods_img_url"/> </td> </tr>
php代码
/*新增*/ $grab_img_url = $_POST['grab_img_url']; if (isset($_FILES['grab_img'])) { // 上传了,直接使用,原始大小 $uplod_grab_img = $image->upload_image($_FILES['grab_img']); if ($goods_thumb === false) { sys_msg($image->error_msg(), 1, array(), false); } } if(empty($uplod_grab_img)){ $grab_img = $grab_img_url; //如果没有上传产品使用默认 }else{ $grab_img = $uplod_grab_img; // 如果有上传商品 则用新图 } /**/