ECShop前端单图片上传

首先确保模板的form有enctype=“multipart/form-data”

//引入封装类并实例化:
include_once(ROOT_PATH . ‘/include/cls_image.php’);
i m a g e = n e w c l s i m a g e ( image = new cls_image( image=newclsimage(_CFG[‘bgcolor’]);

//获取前端选择的图片信息:
f r e e p h o t o = i s s e t ( freephoto = isset( freephoto=isset(_FILES[‘freephoto’]) ? F I L E S [ ′ f r e e p h o t o ′ ] : ′ ′ ; / / 判 断 格 式 : i f ( i s s e t ( _FILES['freephoto'] : ''; //判断格式: if (isset( FILES[freephoto]:;//if(isset(freephoto[‘error’])){
// 最大上传文件大小
$php_maxsize = ini_get(‘upload_max_filesize’);
h t m m a x s i z e = ′ 2 M ′ ; i f ( htm_maxsize = '2M'; if ( htmmaxsize=2M;if(freephoto[‘error’] == 0)
{
if (! i m a g e − > c h e c k i m g t y p e ( image->check_img_type( image>checkimgtype(freephoto[‘type’]))
{
show_message(KaTeX parse error: Expected 'EOF', got '}' at position 39: …g']); }̲ } …freephoto[‘error’] == 1)
{
show_message(sprintf($_LANG[‘goods_img_too_big’], KaTeX parse error: Expected 'EOF', got '}' at position 24: …ize)); }̲ elseif…freephoto[‘error’] == 2)
{
show_message(sprintf($_LANG[‘goods_img_too_big’], KaTeX parse error: Expected 'EOF', got '}' at position 24: …ize)); }̲ } //完成…other[‘freephoto’] 的值最终是一个图片路径,可直接存入数据库
if ($freephoto[‘name’] != “”){
$other[‘freephoto’] = i m a g e − > u p l o a d i m a g e ( image->upload_image( image>uploadimage(freephoto,‘freephoto’);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值