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



Go to last post Go to first unread
#1 Posted : Wednesday, February 7, 2007 6:42:40 PM(UTC)

Rank: Member

Groups: Member
Joined: 4/11/2006(UTC)
Posts: 6


When the users are uploading pictures on our site we upload their original image and created thumbnail from Aurigma Image Uploader. The Image Uploader settings are as folows:

<script language="javascript">
var iu = new ImageUploaderWriter("ImageUploader", 650, 350);
// If you do not want to use ActiveX or Java version, set the appropriate property to false.
iu.activeXControlEnabled = true;
iu.javaAppletEnabled = true;

iu.activeXControlCodeBase = "ImageUploader4.cab";

// ... initialize params ...
iu.addParam("PaneLayout", "TwoPanes");
iu.addParam("BackgroundColor", "#ffffff");
iu.addParam("UploadThumbnail1FitMode", "Fit");
iu.addParam("UploadThumbnail1Width", "120");
iu.addParam("UploadThumbnail1Height", "120");
iu.addParam("UploadThumbnail1JpegQuality", "50");
iu.addParam("FilesPerOnePackageCount", "1");
iu.addParam("AutoRecoverMaxTriesCount", "5");
iu.addParam("AutoRecoverTimeOut", "1200");
iu.addParam("ShowDebugWindow", "True");
iu.addParam("AdditionalFormName", "Form1");
iu.addParam("AllowRotate", "False");
iu.addParam("UploadSourceFile", "True");
iu.addParam("Action", "actualUpload.aspx");
iu.addParam("FileMask", "*.jpg;*.bmp;*.tiff;*.tif");
iu.addParam("MaxFileSize", "5242880");
iu.addParam("ButtonStopText", "<%=languageText["bStop"]%>");
iu.addParam("ButtonSelectAllText", "<%=languageText["bSelectAll"]%>");
iu.addParam("ButtonDeselectAllText", "<%=languageText["bDeselectAll"]%>");
iu.addParam("ButtonSendText", "<%=languageText["bSend"]%>");
iu.addParam("ProgressDialogTitleText", "<%=languageText["pdUploadFiles"]%>");
iu.addParam("ProgressDialogPreparingDataText", "<%=languageText["pdPreparingData"]%>");
iu.addParam("ProgressDialogCloseWhenUploadCompletesText", "<%=languageText["pdCloseThis"]%>");
iu.addParam("ProgressDialogEstimatedTimeText", "<%=languageText["pdEstimatedTime"]%> [Current] <%=languageText["pdOf"]%> [Total]");
iu.addParam("ProgressDialogCancelButtonText", "<%=languageText["pdCancel"]%>");
iu.addParam("MessageUploadCompleteText", "<%=languageText["pdUploadComplete"]%>");
iu.addParam("MessageSwitchAnotherFolderWarningText", "<%=languageText["SwitchAnotherFolderWarningText"]%>");
iu.addParam("ShowDescriptions", "0");
iu.addParam("CheckFilesBySelectAllButton", "True");
iu.addParam("SilentMode", "false");
iu.addEventListener("Progress", "ImageUploaderID_Progress");

//Get the language to apply localization for.
switch (lang)
	case "sv":
		lang = "en";

function ImageUploaderID_Progress(Status, Progress, ValueMax, Value, StatusText)
	if (Status=="COMPLETE")
		tt = window.setTimeout("doAction()", 4000);
	if (Status=="CANCEL")
		tt = window.setTimeout("doAction()", 4000);


On the other side the code that we use for saving the pictures on the server (on page actualUpload.aspx) is as folows:

protected override void Page_Load(object sender, System.EventArgs e)
			base.Page_Load (sender, e);

			language = Convert.ToInt16 (Session["l"].ToString());

			user = -1;
			if(Session["User_ID"] != null)
				user = Convert.ToInt32 (Session["User_ID"]);
			//Get total number of uploaded files
			int intFileCount = Int32.Parse(Request.Form["FileCount"]);

			string strGalleryPath=System.Configuration.ConfigurationSettings.AppSettings["StoragePath"] + "\\Gallery\\" + Session["Subfolder"] + "\\";
			string strSessionPath = strGalleryPath + Session["index"].ToString();
			if(!Directory.Exists(strSessionPath + "\\Thumbnails"))
				Directory.CreateDirectory(strSessionPath + "\\Thumbnails");

			dirPath = strSessionPath + "\\";

			//We iterate through the uploaded files and save them and appropriate data
			for (int i = 1; i <= intFileCount; i++)
				//Get source image and save it to disk
				sourceFile = Request.Files["SourceFile_" + i];
				thumbFile = Request.Files["Thumbnail1_" + i];	
				tr = new Thread(new ThreadStart(this.NewThread));

private void NewThread()
				uploadLogics (dirPath , sourceFile, thumbFile);
			catch(Exception ex)
				logger.Info("Error while uploading with Aurigma.", ex);

private void uploadLogics(string dirPath, HttpPostedFile sourceFile, HttpPostedFile thumbFile)
			string fileName;
			string ext;
			long size;

			// Get the file name
			fileName = Path.GetFileName(sourceFile.FileName);		

			ext = fileName.Substring(fileName.LastIndexOf("."));
			fileName = fileName.Substring(0,fileName.LastIndexOf("."));

			fileName = Regex.Replace(fileName, @"[ ',;+%]", "_");

			// If already was uploaded file with that name, change the current file name
			string newFileName = fileName + ext;
			int j = 1;
			while (File.Exists(dirPath + newFileName))
				newFileName = j + "_" + fileName + ext;
			ext = newFileName.Substring(newFileName.LastIndexOf("."));
			fileName = newFileName.Substring(0,newFileName.LastIndexOf("."));

			// Shrink the file name to max 50 characters
			fileName = fileName.Length > 50 ? fileName.Substring(0, 50): fileName; 

			// Save the file 
				sourceFile.SaveAs(dirPath + fileName + ext);
                                                   [color=#ff0000]size = sourceFile.InputStream.Length;[/color]

				//Get first thumbnail (the single thumbnail in this code sample)
				thumbFile.SaveAs (dirPath + "Thumbnails\\" + fileName + ext);

				DBPhoto dbPhoto = new DBPhoto();
				dbPhoto.insertImage(Convert.ToInt64(Session["index"]), fileName + ext,0 , language, size, user, -1, -1, -1, -1, Session["Subfolder"]+"");
			catch(Exception ex)
				logger.Error("Error while saving file with Aurigma.", ex);

So the problem that we encounter for the second time now is:

The user uploads his/hers pictures and what it is happening is that on the server side all thumbnails are created right but the original pictures are saved with size in bytes 0. As you could see from the code above (red font row) we get the size in bytes from the stream that Aurigma Image Uploader sends to the actualUpload.aspx page where actualy the pictures are saved. When I've checked the inserts in database I saw that all uploaded pictures (for these two particular cases) have size in bytes value 0 which means that the posted stream was empty?

What could be the problem?

Is there maybe something connected with the browser user uses or some settings in the user browser....?

Thank You in advance.

Best regards

Zoran Zlatanov

Edited by user Wednesday, February 20, 2008 7:32:29 PM(UTC)  | Reason: Not specified

Alex Makhov  
#2 Posted : Thursday, February 8, 2007 2:45:00 PM(UTC)
Alex Makhov

Rank: Advanced Member

Groups: Member
Joined: 8/3/2003(UTC)
Posts: 998

Hello Zoran,

Try to use the SourceFileSize_N field instead. Read the following article regarding this question:

POST Field Reference.

Edited by user Monday, October 27, 2008 11:25:38 PM(UTC)  | Reason: Not specified

Sincerely yours,

Alex Makhov

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.