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";
}