VB中的图像上传问题asp.net [英] Image Uploading Problem asp.net in vb

查看:69
本文介绍了VB中的图像上传问题asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有Vb代码可以上传并显示图像,问题是当我尝试上传图像时它不起作用,但是当我刷新页面然后上传图像时,所以请让我知道问题出在哪里,是否存在缓存或等
谢谢&问候.


Hi,
I have Vb code that Upload And displays Image,Problem is that when I try to upload image then it does not works,But when I Refresh page then Image is uploaded So please Let me know what is the Problem Is there any issue of caching or etc.
Thanks & Regards.


Protected Sub UploadImage(ByVal sender As Object, ByVal e As EventArgs)
       Try
            Dim saveDir As String = ConfigurationManager.AppSettings.Item("BaseApplicationFolder")

           ' Get the physical file system path for the currently
           ' executing application.
           Dim appPath As String = Request.PhysicalApplicationPath
           If Not FACID = txtFacId.Text And Not String.IsNullOrEmpty(txtFacId.Text) Then
               FACID = txtFacId.Text
           End If
           ' Before attempting to save the file, verify
           ' that the FileUpload control contains a file.
           If (fuImage.HasFile) Then
               Dim savePath As String = appPath + "_images\assisted_living\fac_profile_pic\" + _
                   Server.HtmlEncode(fuImage.FileName)
                   If fuImage.FileName.Contains(FACID) Then

                   ' Call the SaveAs method to save the uploaded file to the specified path.
                   ' If a file with the same name already exists in the specified path, the uploaded file overwrites it.
                   If (File.Exists(savePath)) Then
                       File.Delete(savePath)

                   End If

                   fuImage.SaveAs(savePath)

                   Fac_picture.ImageUrl = "..\..\_images\assisted_living\fac_profile_pic\" + FACID + ".jpg"

                   Response.Cache.SetCacheability(HttpCacheability.NoCache)


               Else
                   lbl_message.Text = "The image name and facility name should match."
               End If

           End If
       Catch ex As Exception
           lbl_message.Text = ex.Message

       Finally
           Response.Redirect("UpdateFacilityProfile.aspx?FACID=" & FACID)
       End Try

   End Sub

推荐答案

您需要在此处详细说明问题.是上传图片的问题,即保存在服务器上或在图片框中显示.

据我所知,没有直接的方法可以通过异步/部分回发模式上传图像.您正在使用Ajax吗?如果是,则图像将不会上传,直到您不刷新页面.

删除用于文件上传的Ajax或使用一些技巧将其上传.
You need to elaborate your problem here. Is it matter of uploading the image i.e. saving on server or Showing in Image box.

As I know there is no straight way to upload an image through asynchronous/partial post back mode. Are you using Ajax? If yes, then image will not upload until you will not refresh the page.

Remove Ajax for file uploading or use some trick to upload it.


这篇关于VB中的图像上传问题asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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