coldfusion上传图片

<cfprocessingdirective pageencoding="utf-8">
<cfif isDefined("form.uploadImage")>
<CFSET thisPath = ExpandPath("*.*")>
<CFSET thisDirectory = GetDirectoryFromPath("request.siteurl")>
<cfset filePath = expandPath("#thisDirectory#\shop\upload\")>
<cfif not directoryExists(filePath)>
<cfdirectory action="create" directory="#filePath#">
</cfif>
<cftry>
<cffile action="upload" filefield="upimg" destination="#filePath##imgPath#" accept= "image/bmp,image/png,image/gif,image/jpeg,image/jpg,image/x-png,image/pjpeg" nameconflict="overwrite">
<cfcatch>
<cfset tipmsg="图片格式不正确,只能是jpg、gif和bmp格式图片的才能上传">
</cfcatch>
</cftry>
<cfquery name="updateShopimg" datasource="#request.dsn#">
update shop_info
set images=<cfqueryparam cfsqltype="cf_sql_varchar" value="shop/upload/#imgPath#">
where shop_id=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.uplod_shopId#">
</cfquery>
<cflocation url="#request.siteurl#index.cfm/action/shop.detail/shopid/#url.shopid#" addtoken="no">
</cfif>


<div id="divUploadContent">
<div id="shafridBox" width="200">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="19" height="19" class="l_top_angle"> </td>
<td class="top_ct"> </td>
<td width="19" height="19" class="r_top_angle"> </td>
</tr>
<tr>

<td width="19" class="l_ct"> </td>
<td height="30" align="center" valign="middle" style="background-color:#FFFFFF;">
<div class="shafridBoxCt" style="background-color:#FFFFFF;">

<div class="shafridBoxCtTl"><span class="fl font14 heavyGray boldFont">上传图片</span><img name="closeModal" style="cursor:pointer" οnclick="$.modal.close();" class="fr" src="/images/wrong_pic.gif" /></div>
<div class="">
<form method="post" enctype="multipart/form-data" action='uploadimage.cfm'>
<table width="70%">
<tr>
<td align="left"><input name="upimg" type="file" value="浏览" accept="jpg|gif">
</td>
</tr>
<tr>
<td align="center"><input type="submit" value="上传" name="uploadImage"></td>
</tr>
</table>
</div>
</td>
<td width="19" class="r_ct"> </td>
</tr>
<tr>
<td width="19" height="19" class="l_bt_angle"> </td>
<td class="bt_ct"> </td>
<td width="19" height="19" class="r_bt_angle"> </td>
</tr>
</table>
<input type="hidden" name="imgPath" id="imgPath" value="<cfoutput>#request.ccid#</cfoutput>.gif">
<input type="hidden" name="uplod_shopId" id="uplod_shopId" value="<cfoutput>#url.shopid#</cfoutput>">
</form>
</div>
</div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值