日期:2014-05-19  浏览次数:20366 次

ASP.NET图片上传,高手帮我解释一下,看不太懂!
dim   fn()   as   string
dim   ft   as   string
dim   fname   as   string
if   upimg.postedfie.contentlength> 0   then
fn=upimg.postedfile.filename.split( "\ ")
ft=right(fn(fn.length-1),4)
if   ft= ".jpg "   ro   ft= ".bmp "   ro   ft= ".gif "   then
fname=trim(str(year(datetime.now)))+trim(str(datetime.now.month))+trim(str(datetime.now.day))+trim(str(datetime.now.hour))+trim(str(datetime.now.second))+trim(str(datetime.now.millisecond))+ft
upimg.postedfile.saveas(server.mappath( ". ")+ "\picfile\ "+fname)
fname= " <center> <img   src=picfile/ "   &   fname   & "   border=0> "   &   iif(textbox5.text <> " ", " <br> "   &   textbox5.text, " ")
textbox4.text+=chr(10)&fname& " </center> "&chr(10)
else
response.write( " <script> alert( '对不起,图片格式不对,请选择正确格式的图片! '); </script> ")
end   if

------解决方案--------------------
contentlength文件大小 split打散 right(fn(fn.length-1),4) 取文件名
if ft= ".jpg " ro ft= ".bmp " ro ft= ".gif " 如果是图片
fname=trim(str(year(datetime.now)))+trim(str(datetime.now.month))+trim 给文件取名
用的今天时间结果是200703152347一般加个随机数什么的
postedfile.saveas(server.mappath文件保存在服务器那里
fname= " <center> <img src=picfile/ " & fname & " border=0> " 如果正确就在前台显示 不正确就报错( " <script> alert 是弹出对话框

不好意思本人初学C# !