// 2013-12-31: GreenRose private void FileUploadComplete(string strFileName) { //byte[] bit = new byte[0]; //VideoInfo videoInfo = new VideoInfo(); //videoInfo.Data = bit; //videoInfo.UserId = Login._UserInfo.Id; //videoInfo.ImgData = bit; //int nIndex = strFileName.LastIndexOf("\\"); //videoInfo.ImgName = strFileName.Substring(nIndex + 1); //Login._ClientEngine.Send(NotifyType.Request_VideoUpload, videoInfo); WebUploader.GetInstance().UploadFile(_strImageFile, _strUri, ImageFileUploadComplete, this); }
private void save_Click(object sender, RoutedEventArgs e) { //string filePath = "C:\\Record\\" + Login._UserInfo.Id + ".avi"; //Microsoft.Win32.OpenFileDialog open = new Microsoft.Win32.OpenFileDialog(); //open.Multiselect = false; //open.FileName = filePath; //open.Filter = "AVI Files (*.avi)|*.avi"; //if ((bool)open.ShowDialog()) //{ // if (filePath == open.FileName) // { // Uploader(open.FileName, open.OpenFile()); // } //} try { //System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); //fileDialog.Multiselect = false; //fileDialog.Filter = "AVI Files (*.avi)|*.avi|WMV Files (*.wmv)|*.wmv|ALL Files (*.*)|*.*"; //fileDialog.Title = "비디오파일선택"; //if (System.Windows.Forms.DialogResult.OK == fileDialog.ShowDialog()) //{ //string fileName = fileDialog.FileName; string fileName = _strRecordFilePath; System.IO.FileInfo fileSize = new System.IO.FileInfo(fileName); if (fileSize.Length > 1024 * 10 * 10 * 10 * 10 / 2) { TempWindowForm tempWindowForm = new TempWindowForm(); QQMessageBox.Show(tempWindowForm, "文件大小必须小于 5MB.", "提示", QQMessageBoxIcon.Error, QQMessageBoxButtons.OK); return; } string strImageFile = fileName.Replace(".mp4", ".jpg"); string strUri = Login._ServerPath; if (strUri[strUri.Length - 1] != '/') { strUri = strUri + "/"; } // 2014-02-09: GReenRose Dispatcher.BeginInvoke(new System.Threading.ThreadStart(delegate { if (Main.loadWnd == null) { Main.loadWnd = new LoadingWnd(); Main.loadWnd.Owner = myHome; Main.loadWnd.ShowDialog(); } })); strUri += "FaceUpload.php"; WebUploader.GetInstance().UploadFile(fileName, strUri, FileUploadComplete, this); _strImageFile = strImageFile; _strUri = strUri; //WebUploader.GetInstance().UploadFile(strImageFile, strUri, ImageFileUploadComplete, this); this.Close(); //if (UpdateFile(fileName)) //{ // if (UpdateFile(strImageFile)) // { // byte[] bit = new byte[0]; // VideoInfo videoInfo = new VideoInfo(); // videoInfo.Data = bit; // videoInfo.UserId = Login._UserInfo.Id; // videoInfo.ImgData = bit; // int nIndex = fileName.LastIndexOf("\\"); // videoInfo.ImgName = fileName.Substring(nIndex + 1); // Login._ClientEngine.Send(NotifyType.Request_VideoUpload, videoInfo); // } //} } catch (Exception ex) { string strError = ex.ToString(); ErrorCollection.GetInstance().SetErrorInfo(strError); } }
private void openFile_Click(object sender, RoutedEventArgs e) { //// Create OpenFileDialog //Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); //// Set filter for file extension and default file extension //dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; //Nullable<bool> result = dlg.ShowDialog(); //// Get the selected file name and display in a TextBox //if (result == true) //{ // Image myImg = new Image(); // BitmapImage myBit = new BitmapImage(); // myBit.BeginInit(); // myBit.UriSource = new Uri(dlg.FileName, UriKind.Absolute); // myBit.EndInit(); // /*********************************/ // char[] delimiterChars = { ':', '\\' }; // string[] words = dlg.FileName.Split(delimiterChars); // int count = words.Length; // JpegBitmapEncoder encoder = new JpegBitmapEncoder(); // encoder.Frames.Add(BitmapFrame.Create(myBit)); // byte[] bit = new byte[0]; // using (MemoryStream stream = new MemoryStream()) // { // encoder.Save(stream); // bit = stream.ToArray(); // stream.Close(); // if (bit.Length >= 120000) // { // //MessageBoxCommon.Show("文件过大上传失败.请上传100KB以下的文件.", MessageBoxType.Ok); // TempWindowForm tempWindowForm = new TempWindowForm(); // QQMessageBox.Show(tempWindowForm, "文件过大上传失败.请上传100KB以下的文件.", "提示", QQMessageBoxIcon.Error, QQMessageBoxButtons.OK); // } // else // { // VideoInfo videoInfo = new VideoInfo(); // videoInfo.Data = bit; // videoInfo.UserId = words[count - 1].ToString(); // videoInfo.ImgData = bit; // videoInfo.ImgName = words[count - 1].ToString(); // Login._ClientEngine.Send(NotifyType.Request_IconUpload, videoInfo); // } // } // /*************************************/ //} try { System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); fileDialog.Multiselect = false; fileDialog.Filter = "ALL Files (*.*)|*.*|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; fileDialog.Title = "请选择图片文件."; if (System.Windows.Forms.DialogResult.OK == fileDialog.ShowDialog()) { foreach (string fileName in fileDialog.FileNames) { System.IO.FileInfo fileSize = new System.IO.FileInfo(fileName); if (fileSize.Length > 1024 * 10 * 10 * 10 * 10 / 2) { continue; } string strUri = Login._ServerPath; if (strUri[strUri.Length - 1] != '/') { strUri = strUri + "/"; } strUri += "FaceUpload.php"; WebUploader.GetInstance().ctrlAlbum = this; progressUpdate.Visibility = Visibility.Visible; WebUploader.GetInstance().UploadFile(fileName, strUri, FileUploadComplete, this); //if (UpdateFile(fileName)) //{ // byte[] bit = new byte[0]; // VideoInfo videoInfo = new VideoInfo(); // videoInfo.Data = bit; // videoInfo.UserId = Login._UserInfo.Id; // videoInfo.ImgData = bit; // int nIndex = fileName.LastIndexOf("\\"); // videoInfo.ImgName = fileName.Substring(nIndex + 1); // Login._ClientEngine.Send(NotifyType.Request_IconUpload, videoInfo); //} nTotalFileCount++; } if (nTotalFileCount == 0) { TempWindowForm tempWindowForm = new TempWindowForm(); QQMessageBox.Show(tempWindowForm, "文件大小必须小于 5MB.", "提示", QQMessageBoxIcon.Error, QQMessageBoxButtons.OK); } } } catch (Exception ex) { string strError = ex.ToString(); ErrorCollection.GetInstance().SetErrorInfo(strError); } }