Rank: Member
Groups: Member
Joined: 4/11/2006(UTC) Posts: 6
|
Hi 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: Code:<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";
iu.javaAppletCodeBase="./";
// ... 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");
//Localization
//Get the language to apply localization for.
switch (lang)
{
case "sv":
sv_resources.addParams(iu);
break;
default:
lang = "en";
en_resources.addParams(iu);
break;
}
iu.writeHtml();
function ImageUploaderID_Progress(Status, Progress, ValueMax, Value, StatusText)
{
if (Status=="COMPLETE")
{
tt = window.setTimeout("doAction()", 4000);
}
if (Status=="CANCEL")
{
tt = window.setTimeout("doAction()", 4000);
}
}
</script>
On the other side the code that we use for saving the pictures on the server (on page actualUpload.aspx) is as folows: Code: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))
Directory.CreateDirectory(strSessionPath);
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));
tr.Start();
}
}
private void NewThread()
{
try
{
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;
j++;
}
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
try
{
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"]+"");
dbPhoto.closeConn();
}
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
|