如何通过asp上传文件:上传文件控件 [英] how to upload file by asp:upload file control

查看:67
本文介绍了如何通过asp上传文件:上传文件控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有

我想使用aspfile上传控件上传文件,但它可以正常工作,但是如果我使用母版页,则无法正常工作
消息

dear all

i want to upload file with aspfile upload control it work but if i use master page it not work
message

If Upload.HasFile Then
           filename = Path.GetFileName(Me.Upload.FileName)
           Dim extension As String = Path.GetExtension(Me.Upload.FileName)
           Dim allowedExtensions As [String]() = {".png", ".jpeg", ".jpg", ".gif"}
           For i As Integer = 0 To allowedExtensions.Length - 1
               If extension = allowedExtensions(i) Then
                   FileOK = True
               End If
           Next
       End If


如果条件为假
解决方法.
请帮助我


if condition is false
how to solve it.
Please help me

推荐答案

第一件事,我假设您不是要上传文件,而是将其放在更新面板中,希望文件可以异步上传.普通文件上传控件需要完整的回发.

然后尝试将enctype="multipart/form-data"放在表单标签上.

如果这不起作用,可能是由于您的母版页实现以及您如何处理UI,请查看是否发生以下任何情况:
在异步更改可见性时修复FileUpload [带有母版页,Ajax更新面板,FormView和对象数据源的文件上传 [ ^ ]
First thing, I assume you are not trying to upload the file putting it in an update panel expecting file to upload async. Normal file Upload control needs a complete postback.

Then try putting enctype="multipart/form-data" on the form tag.

If that does not work, may be because of your master page implementation and how you are handling the UI, see if any of the following scenario happened:
Fixing FileUpload when Visibility is Changed Asynchronously[^]


Or else, please have a look at this article to see how it can be done:
FileUpload with Master Page, Ajax Update Panel, FormView and Object Data Source[^]


这篇关于如何通过asp上传文件:上传文件控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆