| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 396 人关注过本帖
标题:ASP图片上传出现的问题,希望有人能给解答一下
取消只看楼主 加入收藏
nirendao
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-1-4
收藏
 问题点数:0 回复次数:0 
ASP图片上传出现的问题,希望有人能给解答一下
正在学ASP,现在遇到一个上传图片的问题,点上传提示无法显示页面,我把UPPHOTO.asp换成别的文件,点上传,都显示正常,所以我怀疑问题出现在UPPHOTO.asp上,希望大家能给指点下,谢谢,新人,手头没有分,希望各位大大见谅
图片附件: 游客没有浏览图片的权限,请 登录注册


上传界面的代码
程序代码:
<!--#include file="Config.asp"-->
<%
Dim filepath,layerName,formName,EditName
filepath=""&FormatSQL(SafeRequest("filepath",0))&"/"
layerName=FormatSQL(SafeRequest("layerName",0))
formName=FormatSQL(SafeRequest("formName",0))
EditName=FormatSQL(SafeRequest("EditName",0))
PicSetting=FormatSQL(SafeRequest("PicSetting",0))
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件上传系统</title>
<link href="SSC_Admin.css" rel="stylesheet" type="text/css">
</head>
<body>
<script language="javascript">
function mysubmit(UpfileForm)
{
    if(UpfileForm.filename.value=="")
    {
    alert("请点击浏览按钮,选择您要上传的jpg、gif或bmp文件!")
    return (false);
    }
    else
    {
    str= UpfileForm.filename.value;
    strs=str.toLowerCase();
    lens=strs.length;
    extname=strs.substring(lens-4,lens);
    if(extname!=".jpg" && extname!=".gif" && extname!=".bmp" )
    {
    alert("请选择jpg、gif或bmp文件!");
    return (false);
    }
    }
    return (true);
}
</script>
<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<form name="UpfileForm" method="post" action="UpPhoto.asp" enctype="multipart/form-data" onsubmit="return mysubmit(this)">
  <tr>
    <td height="50" align="center" valign="middle"><input type="hidden" name="act" value="upload">
    <input type="hidden" name="LayerName"  value="<% =LayerName %>">
    <input type="hidden" name="filepath"  value="<% =filepath %>">
    <input type="hidden" name="EditName" value="<% =EditName %>">
    <input type="hidden" name="FormName" value="<% =FormName %>">
    <input type="hidden" name="PicSetting" value="<% =PicSetting %>">
    <input name="filename" type="file" class="InputButton2" value="" size="18">
    <input type="submit" name="Submit" value="上传" class="InputButton"></td>
  </tr>
  <tr>
    <td height="50" align="center" valign="middle"><input name="CloseButton" type="button" class="InputButton" id="CloseButton" value="关闭" onClick="javascript:parent.document.all.<% =LayerName %>.style.visibility='hidden';"></td>
  </tr>
</form>
</table>
</body>
</html>

提示上传成功,程序实现的代码
程序代码:
<%OPTION EXPLICIT%>
<% Server.ScriptTimeOut=5000 %>
<!--#include file="Config.asp"-->
<!--#include file="Conn.asp"-->
<!--#include FILE="upload_5xsoft.inc"-->
<html>
<head>
<title>文件上传</title>
<link href="SSC_Admin.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><%
dim upload,file,FileExt,FormName,formPath,filepathname,RandFileName,iCount
set upload=new upload_5xsoft ''建立上传对象

// Response.Write upload.Version&"<br><br>"  ''显示上传类的版本

if upload.form("filepath")="" then   ''得到上传目录
 msg "请输入要上传至的目录!"

 set upload=nothing

 Response.End
else

 formPath=upload.form("filepath")

 ''在目录后加(/)
 if right(formPath,1)<>"/" then formPath=formPath&"/"
end if

iCount=0

 for each formName in upload.objFile ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据


 FileExt=mid(File.FileName,InStrRev(File.FileName, ".")+1)

 RandFileName=year(now)&"-"&month(now)&"-"&day(now)&"-"&hour(now)&minute(now)&second(now)&"."&FileExt

  file.SaveAs Server.mappath(formPath&RandFileName)   ''保存文件
  '' Response.Write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" 成功!<br>"
if left(formPath,3)="../" then
    formPath=right(formPath,Len(formPath)-3)   ''得到上传相对目录
End if
  filepathname=formPath&RandFileName
  iCount=iCount+1

 end if

 set file=nothing

 next



 //生成缩略图
Dim EditInuptName,PicSetting
EditInuptName=upload.form("EditName")
PicSetting=upload.form("PicSetting")

if PicSetting="ProSetting" then

Dim PicRs,PicSQL,PicSmallWidth,PicSmallHeight,PicBigWidth,PicBigHeight,IsJpegShow,JpegFontName,JpegFontColor,JpegFontFamily
Dim JpegFontBold,JpegFontSize,JpegFontShadowShow,JpegFontShadowColor,JpegCanvasWidth,JpegCanvasHeight,IsJpegPenShow
Dim JpegPenColor,JpegPenWidth,JpegAlphaValue,IsPlugIn,IsBuildCanvasPhoto
    PicSQL="Select * From [SSC_ProSetting] Where ID=1"
    Set PicRs= Server.CreateObject("ADODB.Recordset")
    PicRs.Open PicSQL,Conn,1,1
    if Not PicRs.EOF then
        PicSmallWidth=PicRs("PicSmallWidth")
        PicSmallHeight=PicRs("PicSmallHeight")
        PicBigWidth=PicRs("PicBigWidth")
        PicBigHeight=PicRs("PicBigHeight")
        IsPlugIn=PicRs("IsPlugIn")  //是否使用组件
        IsBuildCanvasPhoto=PicRs("IsBuildCanvasPhoto")  //是否生成缩略图
        IsJpegShow=PicRs("IsJpegShow")  //是否使用水印
        JpegFontName=PicRs("JpegFontName")
        JpegFontColor="&H"&Right(PicRs("JpegFontColor"),6)
        JpegFontFamily=PicRs("JpegFontFamily")
        JpegFontBold=PicRs("JpegFontBold")
        JpegFontSize=PicRs("JpegFontSize")
        JpegFontShadowShow=PicRs("JpegFontShadowShow")
        JpegFontShadowColor="&H"&Right(PicRs("JpegFontShadowColor"),6)
        JpegCanvasWidth=PicRs("JpegCanvasWidth")
        JpegCanvasHeight=PicRs("JpegCanvasHeight")
        IsJpegPenShow=PicRs("IsJpegPenShow")   //是否使用图片边框
        JpegPenColor="&H"&Right(PicRs("JpegPenColor"),6)
        JpegPenWidth=PicRs("JpegPenWidth")
        JpegAlphaValue=PicRs("JpegAlphaValue")/100
   
    End if
PicRs.Close
Set PicRs=Nothing



if IsPlugIn=1 then
//是否使用组件 

Dim sOriginalPath,sSmallPath  //原图路径, 缩略图路径

//sOriginalPath = "../uploads/pic.jpg" 测试使用
sOriginalPath = "../"&filepathname
//原图片路径一般上传完毕后获取,或者从数据库获取
sSmallPath=sOriginalPath //缩略图路径

Dim sReturnInfo, sReturnInfoSmall //函数返回大小图路径信息

select case IsBuildCanvasPhoto
    case "0" 
    //不自动生成缩略图
        select case EditInuptName
            case "SmallPicUrl"
                sReturnInfo = BuildPicCanvas(sOriginalPath, "../Uploads", PicSmallWidth, PicSmallHeight,"1")
            case else
                sReturnInfo = BuildPicCanvas(sOriginalPath, "../Uploads", PicBigWidth, PicBigHeight,"0")
            End select
    case "1" 
    //自动生成缩略图
        sReturnInfo = BuildPicCanvas(sOriginalPath, "../Uploads", PicBigWidth, PicBigHeight,"0")
        sReturnInfoSmall = BuildPicCanvas(sOriginalPath, "../Uploads", PicSmallWidth, PicSmallHeight,"1")
End select


//Response.Write "返回信息:" & sReturnInfo & "<br/>"
If InStr(sReturnInfo, "Error_") <= 0 Then
     sSmallPath = sReturnInfo //返回信息就是
     //将sSmallPath写入数据库
Else
     Response.Write "详细错误:"
     Select Case sReturnInfo
     Case "Error_01"
         Response.Write "<font color='red'>创建AspJpeg组件失败,没有正确安装注册该组件</font>" & "<br/>"
     Case "Error_02"
         Response.Write "<font color='red'>原图片不存在,检查s_OriginalPath参数传入值</font>" & "<br/>"
     Case "Error_03"   
         Response.Write "<font color='red'>缩略图存盘失败.可能原因:缩略图保存基地址不存在,检查s_OriginalPath参数传入值;对目录没有写权限;磁盘空间不足</font>" & "<br/>"
     Case "Error_Other"
         Response.Write "<font color='red'>未知错误</font>" & "<br/>"
     End Select
     Response.End()
End If

End if  //是否自动生成缩略图

if IsJpegShow=1 then 
//是否加入文字水印
    if EditInuptName="BigPicUrl" or IsBuildCanvasPhoto=1 then
        Dim JpegReturnInfo
        JpegReturnInfo=BuildJpegCanvasFont(sReturnInfo,IsJpegShow,JpegFontName,JpegFontColor,JpegFontFamily,JpegFontBold,JpegFontSize,JpegFontShadowShow,JpegFontShadowColor,JpegCanvasWidth,JpegCanvasHeight,IsJpegPenShow,JpegPenColor,JpegPenWidth,JpegAlphaValue)
    End if
End if

End if  //是否使用组件

if IsBuildCanvasPhoto=1 then
     Response.Write"<script>parent."&upload.form("formname")&".SmallPicUrl.value='"&Right(sReturnInfoSmall,Len(sReturnInfoSmall)-3)&"';</script>"
    Response.Write"<script>parent."&upload.form("formname")&".BigPicUrl.value='"&Right(sReturnInfo,Len(sReturnInfo)-3)&"';</script>"
else
     Response.Write"<script>parent."&upload.form("formname")&"."&upload.form("EditName")&".value='"&filepathname&"';</script>"

 End if

 Response.Write"<script>parent.document.all."&upload.form("LayerName")&".style.visibility='hidden';</script>"

 Set upload=nothing  //删除此对象

%>
<script language="javascript">
window.alert("文件上传成功!");
window.history.back();
</script>
</td>
  </tr>
</table>
</body>
</html>
搜索更多相关主题的帖子: 图片 
2012-01-04 09:02
快速回复:ASP图片上传出现的问题,希望有人能给解答一下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.068380 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved