Esempio n. 1
0
        /// <summary>
        /// Updates this instance.
        /// </summary>
        public void Update()
        {
            if (RemovePicture.Checked)
            {
                MetaHelper.SetMetaFile(MetaField.Context, MetaObject, MetaField.Name, String.Empty, String.Empty, null);
                return;
            }

            byte[] data = null;
            if (MetaValueCtrl.PostedFile != null && MetaValueCtrl.PostedFile.ContentLength > 0)
            {
                //To create a PostedFile
                McHttpPostedFile File = MetaValueCtrl.PostedFile;

                if (File.ContentLength == 0)
                {
                    return;
                }

                //if (!MetaField.ImageProperty.AutoResizeImage || File.ContentType.Contains("gif"))
                {
                    //Create byte Array with file len
                    data = new Byte[File.ContentLength];

                    //force the control to load data in array
                    File.InputStream.Read(data, 0, File.ContentLength);
                }
                //else
                {
                    //data = ImageGenerator.CreateImageThumbnail(File.InputStream, File.ContentType, MetaField.ImageProperty.ImageHeight, MetaField.ImageProperty.ImageWidth, MetaField.ImageProperty.StretchImage);
                }

                MetaHelper.SetMetaFile(MetaField.Context, MetaObject, MetaField.Name, File.FileName, File.ContentType, data);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the ServerClick event of the btnUpload control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnUpload_ServerClick(object sender, EventArgs e)
        {
            Encoding encoding = Encoding.UTF8;

            McHttpPostedFile file = mcHtmlInputFile.PostedFile;

            if (file != null)
            {
                byte[] data = new Byte[file.ContentLength];
                file.InputStream.Read(data, 0, file.ContentLength);
                CommerceLicensing.SetLicense(encoding.GetString(data));
                BindControls();
            }
        }
        private void Process()
        {
            string _containerName = "FileLibrary";
            string _containerKey = "EMailAttach";
            CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(_containerName, _containerKey);
            CS.FileStorage fs = (CS.FileStorage)bic.LoadControl("FileStorage");
            CS.DirectoryInfo di = fs.GetDirectory(fs.Root.Id, guid, true);

            for (int Index = 0; Index < Request.Files.Count; Index++)
            {
                if(!String.IsNullOrEmpty(Request.Files[Index].FileName))
                    using (McHttpPostedFile PostedFile = new McHttpPostedFile(Request.Files[Index]))
                    {
                        if (PostedFile.InputStream != null)
                            fs.SaveFile(di.Id, PostedFile.FileName, PostedFile.InputStream);
                    }
            }
        }
        private void Process()
        {
            string _containerName = "FileLibrary";
            string _containerKey  = "EMailAttach";

            CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(_containerName, _containerKey);
            CS.FileStorage      fs  = (CS.FileStorage)bic.LoadControl("FileStorage");
            CS.DirectoryInfo    di  = fs.GetDirectory(fs.Root.Id, guid, true);

            for (int Index = 0; Index < Request.Files.Count; Index++)
            {
                if (!String.IsNullOrEmpty(Request.Files[Index].FileName))
                {
                    using (McHttpPostedFile PostedFile = new McHttpPostedFile(Request.Files[Index]))
                    {
                        if (PostedFile.InputStream != null)
                        {
                            fs.SaveFile(di.Id, PostedFile.FileName, PostedFile.InputStream);
                        }
                    }
                }
            }
        }