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

Notification

Icon
Error

Options
Go to last post Go to first unread
jgibbs  
#1 Posted : Sunday, November 9, 2008 8:39:33 PM(UTC)
jgibbs

Rank: Advanced Member

Groups: Member
Joined: 9/22/2008(UTC)
Posts: 39

I'm trying to upload 3 thumbnails (the original, but ActualSize so it'll preserve rotation of the image, one that fits a 500 x 500 area, and then one that fist a 200 x 150 area).

I can successfully get the original, and the other two uploaded...but the original is just the "sourcefile" and not a thumbnail preserving the rotation. So, I read the manual and I tried what it says in order to upload a thumbnail which would be the original but preserving the rotation. When I set :

Code:
iu.addParam("UploadSourceFile", "false");


and then put this in my default.aspx file:

Code:
  //Thumbnail 1
            iu.addParam("UploadThumbnail1FitMode", "ActualSize"); 
            iu.addParam("UploadThumbnail1CopyExif", "true");

            //Thumbnail 2
            iu.addParam("UploadThumbnail2FitMode", "Fit"); 
            iu.addParam("UploadThumbnail2Width", "500");
            iu.addParam("UploadThumbnail2Height", "500");
            iu.addParam("UploadThumbnail2JpegQuality", "70");
            iu.addParam("UploadThumbnail2CopyExif", "true");

            //Thumbnail 3
            iu.addParam("UploadThumbnail3FitMode", "Fit"); 
            iu.addParam("UploadThumbnail3Width", "200");
            iu.addParam("UploadThumbnail3Height", "150");
            iu.addParam("UploadThumbnail3JpegQuality", "40");
            iu.addParam("UploadThumbnail3CopyExif", "true");


and then in my upload.aspx file I set this to process the files:

Code:
  Dim fileName As String = GetSafeFileName(Path.GetFileName(sourceFile.fileName))

            Dim thumbnail1File As HttpPostedFile = Request.Files("Thumbnail1_" & i)
            thumbnail1File.SaveAs(Server.MapPath(galleryPath & newDir & "/large/" & fileName))

            Dim thumbnail2File As HttpPostedFile = Request.Files("Thumbnail2_" & i)
            thumbnail2File.SaveAs(Server.MapPath(galleryPath & newDir & "/medium/" & fileName))
				
            Dim thumbnail3File As HttpPostedFile = Request.Files("Thumbnail3_" & i)
            thumbnail3File.SaveAs(Server.MapPath(galleryPath & newDir & "/thumbs/" & fileName))


I end up getting an error saying that "Dim fileName As String = GetSafeFileName(Path.GetFileName(sourceFile.fileName)): Object reference not set to an instance of an object." If I then change the default file to:

Code:
iu.addParam("UploadSourceFile", "true");


just so it'll find an instance of the object and then try to upload again, then it says:

Thumbnail1File.SaveAs line is "Object reference not set to an instance of an object. "

Now, as I said before, I can get the original upload (non-rotated) and two thumbnails...but two thumbnails seems to be the limit allowed...not 3 like the manual says. So from what I gather, in order to make a thumbnail, I HAVE to upload the original. But then when I upload the original it won't let me upload more than 2 thumbnails. So, what do I need to do in order to get:

1) Sourcefile not uploaded
2) Thumbnail 1 = original file but preserving rotation
3) Thumbnail 2 and Thumbnail 3 as already set.
jgibbs  
#2 Posted : Sunday, November 9, 2008 9:53:06 PM(UTC)
jgibbs

Rank: Advanced Member

Groups: Member
Joined: 9/22/2008(UTC)
Posts: 39

I read another post with a similar issue regarding the uploadsourcefile. I've modified my default.aspx page to turn off the sourcefile upload. And in my upload.aspx page, I've modified my code to pull the data from the thumbnail rather than the "sourcefile". But I'm still getting an "Object reference not set to an instance of an object." message.

Here's my new upload.aspx code that's apparently not seeing a thumbnail request.

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	
'Get total number of uploaded files (all files are uploaded in a single package).
Dim fileCount As Integer = Int32.Parse(Request.Form("FileCount"))
Dim PackageIndex As String = Int32.Parse(Request.Form("PackageIndex"))
Dim newDir As String = request.Form("randomDir")
Dim theUsername As String = request.form("username")
			
'Create the directories to upload the images too
Directory.CreateDirectory(Server.MapPath(galleryPath & newDir & "/large"))	'large source file directory
Directory.CreateDirectory(Server.MapPath(galleryPath & newDir & "/medium"))	'medium sized thumb directory
Directory.CreateDirectory(Server.MapPath(galleryPath & newDir & "/thumbs"))	'small sized thumb directory
'Iterate through uploaded data and save the original file, thumbnail, and description.
			
For i As Integer = 1 To fileCount
   Dim thePhotoID As String = newDir & "_" & PackageIndex
   Dim thumbnail1File As HttpPostedFile = Request.Files("Thumbnail1_" & i)
   Dim fileName1 As String = GetSafeFileName(Path.GetFileName(thumbnail1File.fileName))
   thumbnail1File.SaveAs(Server.MapPath(galleryPath & newDir & "/large/" & fileName1))

   Dim thumbnail2File As HttpPostedFile = Request.Files("Thumbnail2_" & i)
   Dim fileName2 As String = GetSafeFileName(Path.GetFileName(thumbnail2File.fileName))
   thumbnail2File.SaveAs(Server.MapPath(galleryPath & newDir & "/medium/" & fileName2))
				
   Dim thumbnail3File As HttpPostedFile = Request.Files("Thumbnail3_" & i)
   Dim fileName3 As String = GetSafeFileName(Path.GetFileName(thumbnail3File.fileName))
   thumbnail3File.SaveAs(Server.MapPath(galleryPath & newDir & "/thumbs/" & fileName3))


I feel like I'm getting close...but it's saying that "dim filename1 As String" isn't set to an object.

HELP!
Dmitry  
#3 Posted : Monday, November 10, 2008 2:33:11 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

I prepared small sample site based on your server script. Please, try it out.
File Attachment(s):
ActualSize.zip (1,908kb) downloaded 3 time(s).
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
jgibbs  
#4 Posted : Tuesday, November 11, 2008 8:30:27 PM(UTC)
jgibbs

Rank: Advanced Member

Groups: Member
Joined: 9/22/2008(UTC)
Posts: 39

Dmitry,

This seems to be the exact same code that I already have. I copied your code and it's the same as what mine is...the only difference is that I have more code than the basic options and I'm also using the threepane and not the two panes. I'm going to open up a ticket and attach my code to give you a closer look at what I have going on.
Dmitry  
#5 Posted : Wednesday, November 12, 2008 3:51:45 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Okay, please, post it in the case because the sample works correctly for me.
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
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.