-
Mar 11th, 2017, 09:57 PM
#1
Thread Starter
Junior Member
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.
-
Mar 11th, 2017, 10:24 PM
#2
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|