我已经创建了ShadowUpload.asp和Upload.asp。 它有效,但是,我想显示上传的图片,但我不知道如何显示它
我的源代码是
<!-- #include file="ShadowUpload.asp" -->
<form action="<%=Request.ServerVariables( "Script_Name" )%>?action=1" enctype="multipart/form-data" method="POST">
Picture Profile: <input type="file" name="file1" value="<%=myPicture%>" /><br />
<button type="submit">Upload</button>
</form>
<img border="0" src="<%=myPicture%>" width="90" height="100">`
<%
Dim objUpload
If Request("action")="1" Then
Set objUpload=New ShadowUpload
If objUpload.GetError<>"" Then
Response.Write("sorry, could not upload: "&objUpload.GetError)
Else `
Response.Write("found "&objUpload.FileCount&" files...<br />")
For x=0 To objUpload.FileCount-1`
If (objUpload.File(x).ImageWidth>200) Or (objUpload.File(x).ImageHeight>200) Then
Response.Write("image to big, not saving!")
Else
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
Response.Write("file saved successfully!")
End If
Response.Write("<hr />")
Next
End If
End If
%>
答案 0 :(得分:0)
您需要为上传的每个文件添加图片,并且只有在成功上传时才会添加:
If (objUpload.File(x).ImageWidth>200) Or (objUpload.File(x).ImageHeight>200) Then
Response.Write("image to big, not saving!")
Else
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
Response.Write("file saved successfully!")
Response.Write("<br /><img src=""Uploads/" & objUpload.File(x).FileName & """ height=""50"" />")
End If
这将显示已上传图片的预览,设置高度为50像素。