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

Notification

Icon
Error

Options
Go to last post Go to first unread
Daf  
#1 Posted : Thursday, December 3, 2009 9:52:26 PM(UTC)
Daf

Rank: Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 16

Thanks: 1 times
Hi,

I'm implementing a quota system for some users, and have added a :

Code:
ImageUploader1.MaxFileCount = noTestImages - totalImages;


On the back end where "noTestImages" = the max they're allowed and "totalImages" is the number they currently have.

My problem comes when they have reached this max.

Code:
ImageUploader1.MaxFileCount = 0


means no limit.

So I have tried to use

Code:
ImageUploader1.Enabled = false;


BUT it doesn't seem to do anything!
Strangely .Visbile = false; doesn't seem to work either!

I would like to keep the uploader on the page for page structure reasons, just either disable it or disable the Send button but I can't seem to finda way.
Is there a way of getting this to work ?

I guess I could hack it by changing the Denied File Mask to *.* and changing the message. But that's a bit of a hack - I'd rather find a correct way first which would disbale the control or Send button.

I'm using Dual Loader 6.0 on IIS 5.1 on XP - my Dev machine.
Page is ASP.Net 3.x
Viewing through IE 7
Not much on the page other than some divs + uploader control.
Above code (enable=false etc) is placed at the end of Page_Load

Edited by user Thursday, December 3, 2009 10:00:20 PM(UTC)  | Reason: Not specified

Daf  
#2 Posted : Thursday, December 3, 2009 9:55:25 PM(UTC)
Daf

Rank: Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 16

Thanks: 1 times
interestingly

Code:
ImageUploader1.MaxFileCount = -1;


does nothing either. Not even an error.
Tamila  
#3 Posted : Sunday, December 6, 2009 3:35:52 PM(UTC)
Tamila

Rank: Advanced Member

Groups:
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hi Daf,

To resolve your problem you can try to use the following code:
Code:
var maxFile = noTestImages - totalImages;
var iu = new ImageUploaderWriter("ImageUploader1", "800", "600");
//...
if (maxFile == 0){
	iu.addParam("MaxTotalFileSize","1");
	iu.addParam("MessageMaxTotalFileSizeExceededText", "You cannot upload photos in this album");
}
else {
	iu.addParam("MaxFileCount", maxFile);
	iu.addParam("MessageMaxFileCountExceededText", "You cannot upload more than [Limit] photo(s)");
	iu.addParam("MaxTotalFileSize","0");
}
//...
iu.writeHtml();

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
Daf  
#4 Posted : Monday, December 7, 2009 12:36:11 AM(UTC)
Daf

Rank: Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 16

Thanks: 1 times
One thing to note - I am doing most of the work SERVER end, you have given Client end code (i.e. Javascript instead of C#)

Unfortunately your solution doesn't seem to work Server end.
It just uses the standard message.
If I remove the standard message in the ASP.net control it gives no message when trying to add an image to send.

So it seems
C#

Code:
ImageUploader1.MessageMaxTotalFileSizeExceededText


has no effect either.
Is there any solution on the Server end ?
The Object propertise don't seem to want to work.

Edited by user Monday, December 7, 2009 12:42:15 AM(UTC)  | Reason: Not specified

Tamila  
#5 Posted : Monday, December 7, 2009 2:49:15 PM(UTC)
Tamila

Rank: Advanced Member

Groups:
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hi,

Could you please post your full server code here. I will try to propose another solution for you.
Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
Daf  
#6 Posted : Thursday, December 10, 2009 12:04:58 AM(UTC)
Daf

Rank: Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 16

Thanks: 1 times
This is my Page_Load
I've highlighted the areas where I configure the Uploader in RED
Section blocks in BLUE
Comments / commented out code (test) in Olive
The parts we've been discussing above / not working in BOLD

Re-uploading just means keeping the original file name upon upload, rather than renaming. Can be ignored Re discussion about enabling the Uploader.

For the time being I've got around it by hiding the Place Holder that the Uplaoder is in (phUploader.Visible = false;) but as mentioned before - I would rather still show it, just disable any uploading.


=================================================================================
protected void Page_Load(object sender, EventArgs e)
{
pageTitle = WebConfigurationManager.AppSettings["SystemName"].ToString() + " - Image Upload Registration";
Page.Title = pageTitle;
noTestImages = Convert.ToInt32(WebConfigurationManager.AppSettings["UPLOADER_TEST_IMAGES"].ToString());

uploader_pixels_min = WebConfigurationManager.AppSettings["UPLOADER_MIN_PIXELS"].ToString();
uploader_pixels_max = WebConfigurationManager.AppSettings["UPLOADER_MAX_PIXELS"].ToString();
uploader_max_file_size = WebConfigurationManager.AppSettings["UPLOADER_MAX_FILE_SIZE"].ToString();

pnlFailMatch.Attributes.Add("style", "display:none");
pnlFailRef.Attributes.Add("style", "display:none");
pnlOk.Attributes.Add("style", "display:none");
pnlReUpload.Attributes.Add("style", "display:none");

//User Validation
if (!Page.User.Identity.IsAuthenticated)
{
Response.Redirect("/User/Login.aspx?url=" + HttpUtility.UrlEncode(Request.RawUrl));
}

//user
MembershipUser u;
u = Membership.GetUser(User.Identity.Name);
userGUID = (Guid)u.ProviderUserKey;

User userObj = new User(userGUID);
userID = userObj.UserID;
hidUserID.Value = userID.ToString();

//if not authenticated uploader (or registered) - send back
uploaderObj = new UploadUser(userID);


//Test to see if they can RE upload
if (!uploaderObj.ShowUploader)
{
//no show uploader (probably failed application)
Response.Redirect("UploaderRequest.aspx");
}




//enable / disable Re-upload
if (uploaderObj.AccReUpload)
{
//chkReUpload.Visible = true;
phReupload2.Visible = true;
phReupload1.Visible = true;
}
else
{
//chkReUpload.Visible = false;
phReupload2.Visible = false;
phReupload1.Visible = false;
}


#region UploaderConfig
//Uploader Config
//------------------------------------------------------------------

ImageUploader1.FileMask = WebConfigurationManager.AppSettings["UPLOADER_FILE_MASK"].ToString();
ImageUploader1.DeniedFileMask = WebConfigurationManager.AppSettings["UPLOADER_DENIED_FILE_MASK"].ToString();
//Pixels - min
if (!(uploader_pixels_min == "" || uploader_pixels_min == "0"))
{
ImageUploader1.MinImageHeight = Convert.ToInt32(uploader_pixels_min);
ImageUploader1.MinImageWidth = Convert.ToInt32(uploader_pixels_min);
}

//Pixels - max
if (!(uploader_pixels_max == "" || uploader_pixels_max == "0"))
{
ImageUploader1.MaxImageHeight = Convert.ToInt32(uploader_pixels_max);
ImageUploader1.MaxImageWidth = Convert.ToInt32(uploader_pixels_max);
}

//File size
if (!(uploader_max_file_size == "" || uploader_max_file_size == "0"))
{
ImageUploader1.MaxFileSize = Convert.ToInt32(uploader_pixels_max) * 1048576;
ImageUploader1.MessageMaxFileSizeExceededText = "Max file size (jpeg) for upload is " + uploader_pixels_max.ToString() + " Mb";
}


#endregion

#region RestrictNoImages

//Test to see if approved - if not - only upload text No images
//Clear original visiblity

lblRestrictNo.Visible = false;
lblRestrictNoFull.Visible = false;
//ImageUploader1.Enabled = true;
phUploader.Visible = true;

if (uploaderObj.RestrictUpload)
{
//check no already uploaded
DataArchive.Utils.UploaderDL.StatsTableAdapters.UploaderUsersStatsTableAdapter statsTA = new DataArchive.Utils.UploaderDL.StatsTableAdapters.UploaderUsersStatsTableAdapter();
DataArchive.Utils.UploaderDL.Stats.UploaderUsersStatsDataTable statsDT = new Stats.UploaderUsersStatsDataTable();
statsDT = statsTA.GetData(userID);

Int32 totalImages = 0;

if (statsDT.Count > 0)
{
Stats.UploaderUsersStatsRow statsRow = (Stats.UploaderUsersStatsRow)statsDT.Rows[0];

totalImages = statsRow._1 + statsRow._2 + statsRow._3 + statsRow._4 + statsRow.NoStatus; //ignoring 5 = reject
}

//Allow to upload remaining No
if (totalImages >= noTestImages)
{
ImageUploader1.MaxFileCount = -1;
lblRestrictNoFull.Text = "Sorry - you have restricted upload and have reached the max: " + noTestImages.ToString();
lblRestrictNoFull.Visible = true;
ImageUploader1.Enabled = false;
ImageUploader1.Visible = false;

phUploader.Visible = false;
//ImageUploader1.MaxFileSize = 6000; //HACK
//ImageUploader1.MessageMaxTotalFileSizeExceededText = "Sorry - max upload limit reached";


}
else
{
ImageUploader1.MaxFileCount = noTestImages - totalImages;
lblRestrictNo.Text = "There is a restriction to the No of images you can upload, you have uploaded: " + totalImages.ToString() + " of " +noTestImages.ToString();
lblRestrictNo.Visible = true;
}

ImageUploader1.MessageMaxFileCountExceededText = "You cannot upload more than " + noTestImages.ToString() + " images";

}
#endregion


//ImageUploader1.Enabled = false;
//ImageUploader1.Visible = false;
//ImageUploader1.MaxFileCount = -1;
//ImageUploader1.MessageMaxTotalFileSizeExceededText = "TEST";

}
Tamila  
#7 Posted : Thursday, December 10, 2009 2:32:40 PM(UTC)
Tamila

Rank: Advanced Member

Groups:
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hi,

Thank you for the code. I prepared code sample for you:
Code:
//Allow to upload remaining No
if ((noTestImages - totalImages) == 0)
{
//This is a workaround. 
//MaxTotalFileSize = 1 byte, in this case your customer cannot check any file for upload
ImageUploader1. MaxTotalFileSize = 1;
ImageUploader1. MessageMaxTotalFileSizeExceededText = "You cannot upload photos in this album";
}

I hope it helps you.
Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
Daf  
#8 Posted : Thursday, December 10, 2009 5:55:55 PM(UTC)
Daf

Rank: Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 16

Thanks: 1 times
Ah thanks - that worked.

Strange that
Code:
ImageUploader1.MaxFileSize = 1
ImageUploader1.MessageMaxTotalFileSizeExceededText = "Sorry - max upload limit reached";


didn't work.

but this suggestion
Code:
ImageUploader1.MaxTotalFileSize = 1;
ImageUploader1.MessageMaxTotalFileSizeExceededText = "You cannot upload photos in this album";  


Did!

Thanks again.
Daf  
#9 Posted : Thursday, December 10, 2009 5:57:44 PM(UTC)
Daf

Rank: Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 16

Thanks: 1 times
Looking back,
I may have confused
MessageMaxTotalFileSizeExceededText
+
MessageMaxFileCountExceededText
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.