Welcome Guest Search | Active Topics | Sign In | Register

Write files from AJAX Uploader to SQL Server VB.NET 1.1 Options
Peter
Posted: Sunday, January 29, 2012 10:12:24 PM
Rank: Member
Groups: Member

Joined: 8/30/2011
Posts: 17
I'm replacing the standard Visual Studio file uploader with the EO.Web.AJAXUploader to allow multiple files to be uploaded concurrently. The problem I have is converting the file(s) to a byrte array. My stored procedure successfully inserts records from the standard file uploader by using code similar to the following to convert the file to a System.IO.Stream object:

Private Function GetArrayFromFileField(ByVal FileField as System.Web.UI.HtmlControls.HtmlInputFile) as Byte()
Dim intFileLength as Integer, bytData() as Byte, objStream as System.IO.Stream
If FileFieldSelected(FileField) Then
intFileLength = FileField.PostedFile.ContentLength
ReDim bytData(intFileLength)
objStream = FileField.PostedFile.InputStream
objStream.Read(bytData, 0, intFileLength)
Return bytData
End If
End Function

How do I do the same thing (get the Byte array) from the AJAX Uploader? My environment is ASP.NET 1.1 and VB.NET
eo_support
Posted: Monday, January 30, 2012 9:42:28 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Our AJAXUploader always save the file contents into a temp file first (so that no matter how big the file is, you won't run out of memory). Once the uploading is done, our uploader gives you the temp file name. You can then do whatever with that temp file name (read all the bytes and write it to db, or move the file, or delete it, etc).

See here for sample code about how to get the temp file name:

http://demo.essentialobjects.com/Demos/AJAX%20Uploader/Server%20Side%20Event/Demo.aspx

Thanks
Peter
Posted: Monday, January 30, 2012 5:06:29 PM
Rank: Member
Groups: Member

Joined: 8/30/2011
Posts: 17
Thanks for the prompt response. I understand how to loop through the collection and get the tempFileName but I'm having trouble with the equivalent code to the following:

In the standard Windows uploader there is a method to stream the data from the file into System.IO.Stream, for example:

objStream = FileField.PostedFile.InputStream

There isn't an equivalent method in the AJAXUploader that I can see, i.e. how do I get the data from the temporary file into the byte array so I can store it in my database? Do I even need to use a System.IO.Stream or is there another way to convert the contents of the temporary file into a Byte Array so I can store it in the database? My existing code (see original post) works fine but it has to upload and save each file directly into the database one at a time which is not as efficient as your AJAX uploader.

In summary I just need to know how to move the contents of the file into a Byte Array.

Thanks
eo_support
Posted: Monday, January 30, 2012 5:12:42 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You are basically asking us how to get a byte array from a file. This is a generic programming question that you need to work out yourself. We are not in a position to answer such programming questions. We tell you what our product does ---- in this case, we tell you our AJAXUploader gives you a temp file name. That's where it ends and you will need to do the rest.

Thanks
Peter
Posted: Monday, January 30, 2012 5:41:47 PM
Rank: Member
Groups: Member

Joined: 8/30/2011
Posts: 17
Very disappointing response! You provide some but not many quality code examples which makes your product difficult to use and integrate into applications. I use tools from Telerik and Infragistics and their support puts yours to shame. Have a nice day!
eo_support
Posted: Monday, January 30, 2012 8:49:54 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Then you should definitely stick with them. What you are doing is like getting mad with your car dealer because they refuse to give you driving directions. At here we support our product. We do not teach you how to write code or help you solve your own programming questions (even if those questions arise while using our product). This is true regardless whether you are already a paid customer or a potential customer who is just trying out our product. The policy is necessary for us to avoid abuse --- if we don’t do that, everyone who runs into any kind of problems would just come to us to ask us to work it out for them, no matter whether the problem has to do with us or not. So we believe we are being quite reasonable here. If you find anyone who can offer you a more favorable policy, you should go with them.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.