Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
mswhite1997  
#1 Posted : Thursday, June 01, 2006 3:08:27 AM(UTC)
mswhite1997

Rank: Member

Groups: Member
Joined: 6/1/2006(UTC)
Posts: 6

I am wanting to upload my images to a mssql server database. I am wanting to use binary images to upload. At the moment I am using persistsaspupload with Xupload, and AspJpeg when I upload the files I save the original image in the database and also store a resized image using aspJpeg. Does image uploader support doing this, or will I have to pay to get it customized for me.
Thanks Mike
Fedor  
#2 Posted : Friday, June 02, 2006 11:52:58 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,545

Thanks: 5 times
Was thanked: 58 time(s) in 57 post(s)
Hello Mike,
Quote:
I am wanting to upload my images to a mssql server database. I am wanting to use binary images to upload. At the moment I am using persistsaspupload with Xupload, and AspJpeg when I upload the files I save the original image in the database and also store a resized image using aspJpeg. Does image uploader support doing this, or will I have to pay to get it customized for me.
Image Uploader supports it out of the box. It can generate several thumbnails on client side (now you generate them on server side using AspJpeg). Image Uploader sends data to server in standard multipart/form-data format, so on server side it can be handled any standard upload component. For example you can use Persists Upload component to process uploaded files. You can get file data using Binary property and then save them in database.
Code:
'We create aspSmartUpload object for uploading images        
Dim objUpload
Set objUpload = Server.CreateObject("Persits.Upload")
objUpload.CodePage = 65001 'UTF8
objUpload.Save

Dim objFile
Set objFile = objUpload.Files("SourceFile_1")
'objFile.Binary contains the file data
See ASP samples in evaluation pakage for more info about using Image Uploader with Persists Upload component. Please let me know, if you need detailed sample how to save uploaded data in database.

Edited by user Wednesday, December 19, 2007 4:25:51 PM(UTC)  | Reason: Not specified

Best regards, Fedor Skvortsov
mswhite1997  
#3 Posted : Monday, June 05, 2006 1:11:10 AM(UTC)
mswhite1997

Rank: Member

Groups: Member
Joined: 6/1/2006(UTC)
Posts: 6

Here is the code I have inserted. My database is MsSQL Server 2005. I am using nvchar datatype in the table for author and description. When I upload it, I get two squares in the record in front of the description and author. How can I correct my code so it won't do this?
Code:
'We create aspSmartUpload object for uploading images        
Set objUpload = Server.CreateObject("Persits.Upload")
objUpload.CodePage = 65001 'UTF8
objUpload.Save

'Set Author parameter value
'ParameterAuthor.Value = objUpload.Form("Author").Value 

'Total amount of uploaded files
intFileCount = objUpload.Form("FileCount").Value

'We run over uploaded images and load it
For I=1 To intFileCount
	'Fetch source images and save it to disk
	Set objFile = objUpload.Files("SourceFile_" & I)
			Connect = "Driver=SQL Server;Server=server;Database=db;UID=user;PWD=password"
		Set rs = Server.CreateObject("adodb.recordset")
		   rs.Open "MYIMAGES", Connect, 2, 3
		   rs.AddNew
		    Set jpeg = Server.CreateObject("Persits.Jpeg")
		  	' open uploaded file from memory
			jpeg.OpenBinary(objFile.Binary)
		  '	 Use Jpeg.Binary to access binary data. For now, it is the original image
			rs("image_blob").Value = Jpeg.Binary
			jpeg.Width = 640
			jpeg.Height = 480
			rs("thumbnail").Value = Jpeg.Binary
			rs("image_blob") = objFile.Binary
			rs("file_id") = objUpload.Form("Author").value
		  rs("filename") = objFile.FileName
		  rs("filesize") = objFile.Size
		  rs("description") = objUpload.Form("Description_" & I).value
		  rs.Update

Edited by user Wednesday, December 19, 2007 4:26:19 PM(UTC)  | Reason: Not specified

Thanks Mike
Fedor  
#4 Posted : Monday, June 05, 2006 10:35:42 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,545

Thanks: 5 times
Was thanked: 58 time(s) in 57 post(s)
Mike,
Quote:
When I upload it, I get two squares in the record in front of the description and author.
I will check it today and let you know. I think it is something like Unicode heading characters.
Best regards, Fedor Skvortsov
Fedor  
#5 Posted : Tuesday, June 06, 2006 9:15:18 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,545

Thanks: 5 times
Was thanked: 58 time(s) in 57 post(s)
Quote:
When I upload it, I get two squares in the record in front of the description and author.
Image Uploader sends data in standard multipart/form-data format and server should parse it accordingly RFC 1867 . We have tested our standard implementation on the following platforms:
  • ASP.NET
  • ASP.NET ( Mono)
  • ColdFusion
  • Perl
  • Python
  • Ruby
  • JSP (Apache FileUpload classes and Resin server)
  • ASP (AspSmartUpload, ABCUpload, Dundas Upload)
And it worked perfectly... It seems the problem is in Persists Upload component :(. It adds leading new line characters (#13#10) to any extracted form value. We have confirmed the problem with both ActiveX and Java version. In last one we use the 3rd-party upload mechanism. That's why we are sure that the problem is not on our side. Right now as workaround I just recomend you to trim 2 leading characters from any string extracted via PersitsUpload Form collection.
Best regards, Fedor Skvortsov
Fedor  
#6 Posted : Tuesday, June 06, 2006 9:17:53 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,545

Thanks: 5 times
Was thanked: 58 time(s) in 57 post(s)
I also want to add that I have used the following simple function to clear the data:
Code:
'WORKAROUND: Persits Upload component adds two #13#10 leading characters during form value parsing.
Function RemoveLeadingCharacters(Value)
	If Len(Value) < 2 Then
		RemoveLeadingCharacters = Value
	Else
		RemoveLeadingCharacters = Right(Value, Len(Value) - 2)
	End If
End Function

'....
'The sample of using
intFileCount = CInt(RemoveLeadingCharacters(objUpload.Form("FileCount").Value))

Edited by user Wednesday, December 19, 2007 4:26:32 PM(UTC)  | Reason: Not specified

Best regards, Fedor Skvortsov
mswhite1997  
#7 Posted : Wednesday, June 07, 2006 4:56:24 AM(UTC)
mswhite1997

Rank: Member

Groups: Member
Joined: 6/1/2006(UTC)
Posts: 6

THANKS, THAT FIXED IT.
Thanks Mike
Users browsing this topic
Forum Jump  
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.