Results 1 to 2 of 2

Thread: AjaxFileUpload PostedFile and other issues from converting over from fileUpload

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2017
    Posts
    27

    AjaxFileUpload PostedFile and other issues from converting over from fileUpload

    Hello All;

    I have been messing around with different AJAX Upload scripts throughout the day.
    And I found one that I quite like, (AjaxFileUpload) but trying to get it to work with my Upload script along
    With the other scripts in my current FileUpload codebehind, is being a real pain.

    (I have looked and looked for alternative ways of writing this, to make it work, and it is being a pain)

    Issues:
    (MyFile = FileUpload Control)

    Dim myFile As HttpPostedFile = MyFile.PostedFile
    (PostedFile is not a member of 'AjaxFileUpload')

    There are more but to work through them one by one, is the best way.
    As one will help to resolve others, and then narrow down the ones that need attention.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Feb 2017
    Posts
    27

    Re: AjaxFileUpload PostedFile and other issues from converting over from fileUpload

    OK.
    I did the following for the above code sample, however. I am uncertain if this is the right way to write it or not.

    (MyFile = FileUpload Control)
    Dim myFile As HttpPostedFile = MyFile.PostedFile
    converted to------------
    Dim strUploadPath As String = "/Images/"
    Dim myfile As HttpPostedFile = HttpContext.Current.Request.Files(strUploadPath)

    This helped me to get rid of all the other errors, however. When I run the script, it gives an error on the upload.
    But, it does not really give me anything to go by.
    So, I commented out code lines and revealed one-line-at-a-time
    Until I was able to find the line that was causing the error.

    Code:
    Dim nfileLen As Integer = myfile.ContentLength ' This is the first line that it comes too that causes the error.
    ' The rest of the code that goes with this.
                    If nfileLen > 0 Then
                        'Allocate a buffere for reading of the file
                        Dim myData As Byte() = New Byte(nfileLen - 1) {}
                        myfile.InputStream.Read(myData, 0, nfileLen)
    
                        Dim strfilename As String = Path.GetFileName(myfile.FileName)
                        Dim nFileID As Integer = WritetoDB(strfilename, myfile.ContentType, myData)
                    End If

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width