示例#1
0
        ///// <summary>
        ///// 上传视频
        ///// </summary>
        //public static string UploadVideo(UploadedFile oFile)
        //{
        //    try
        //    {

        //        // Get the uploaded file name.
        //        string sFileName = System.IO.Path.GetFileName(oFile.ClientName);//原文件名
        //        if (sFileName != "")
        //        {
        //            string FileTxt = System.IO.Path.GetExtension(oFile.ClientName);//扩展名
        //            string nFileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString();//当前时间
        //            Random sran = new Random();//取随机数;
        //            string Rand = sran.Next(1, 9).ToString();

        //            sFileName = nFileName + Rand + FileTxt;//新的文件名(当前时间+1位随机数)
        //            string reFileName = sFileName;//返回

        //            //取保存目录
        //            string sFilePath = ConfigurationManager.AppSettings["VideoUpload"];
        //            //上传时间月份的文件夹(如:2007-1)
        //            //edit by yjihrp
        //            //string reFileP = "http://flv.ipow.cn" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
        //            string reFileP = "http://sys.ipow.cn/upload" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
        //            sFilePath = "~/Upload" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";

        //            //建立目录
        //            FileDirectoryHelper.CreateFolder(sFilePath);
        //            string reFilePath = sFilePath;//返回

        //            //路径
        //            sFilePath = System.Web.HttpContext.Current.Server.MapPath(sFilePath);

        //            string strFilePath = System.IO.Path.Combine(sFilePath, sFileName);

        //            oFile.SaveAs(strFilePath);


        //            string returntemp = reFileP + "|" + reFileName;
        //            return returntemp;
        //        }
        //        else
        //        {
        //            return null;
        //        }
        //    }
        //    catch
        //    {
        //        return null;
        //    }
        //}

        /// <summary>
        /// 上传视频 edit by yjihrp 2011.4.12
        /// </summary>
        public static string ClientUploadVideo(HttpPostedFile f)
        {
            try
            {
                // Get the uploaded file name.
                string sFileName = System.IO.Path.GetFileName(f.FileName);//原文件名
                if (sFileName != "")
                {
                    string FileTxt   = System.IO.Path.GetExtension(f.FileName);                                                                                                                                                                                           //扩展名
                    string nFileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString(); //当前时间
                    Random sran      = new Random();                                                                                                                                                                                                                      //取随机数;
                    string Rand      = sran.Next(1, 9).ToString();
                    sFileName = nFileName + Rand + FileTxt;                                                                                                                                                                                                               //新的文件名(当前时间+1位随机数)
                    string reFileName = sFileName;                                                                                                                                                                                                                        //返回
                    //取保存目录
                    string sFilePath = ConfigurationManager.AppSettings["VideoUpload"];
                    //上传时间月份的文件夹(如:2007-1)
                    //edit by yjihrp 2011.4.11
                    //string reFileP = "http://flv.ipow.cn" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
                    string reFileP = "http://flv.ipow.cn" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
                    sFilePath = "~/Upload" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
                    //建立目录
                    FileDirectoryHelper.CreateFolder(sFilePath);
                    string reFilePath = sFilePath;//返回
                    //路径
                    //  sFilePath = System.Web.HttpContext.Current.Server.MapPath(sFilePath);
                    string copySFilePath = System.Web.HttpContext.Current.Server.MapPath(sFilePath);
                    string strFilePath   = System.IO.Path.Combine(copySFilePath, sFileName);
                    f.SaveAs(strFilePath);

                    // edit by yjihrp 2011.4.14
                    string       ffPath = System.Web.HttpContext.Current.Server.MapPath("~/Upload/flv/ffmpeg.exe");
                    FfmpegHelper ffmpeg = new FfmpegHelper(ffPath);
                    ffmpeg.ToJpg(strFilePath);
                    string catchImgFileName = System.IO.Path.ChangeExtension(reFileName, ".jpg");
                    string returntemp       = reFileP + "|" + reFileName + "|" + catchImgFileName;
                    //string returntemp = reFileP + "|" + reFileName ;
                    return(returntemp);
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
        }
示例#2
0
        ///// <summary>
        ///// 上传视频
        ///// </summary>
        //public static string UploadVideo(UploadedFile oFile)
        //{
        //    try
        //    {
        //        // Get the uploaded file name.
        //        string sFileName = System.IO.Path.GetFileName(oFile.ClientName);//原文件名
        //        if (sFileName != "")
        //        {
        //            string FileTxt = System.IO.Path.GetExtension(oFile.ClientName);//扩展名
        //            string nFileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString();//当前时间
        //            Random sran = new Random();//取随机数;
        //            string Rand = sran.Next(1, 9).ToString();
        //            sFileName = nFileName + Rand + FileTxt;//新的文件名(当前时间+1位随机数)
        //            string reFileName = sFileName;//返回
        //            //取保存目录
        //            string sFilePath = ConfigurationManager.AppSettings["VideoUpload"];
        //            //上传时间月份的文件夹(如:2007-1)
        //            //edit by yjihrp
        //            //string reFileP = "http://flv.ipow.cn" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
        //            string reFileP = "http://sys.ipow.cn/upload" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
        //            sFilePath = "~/Upload" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
        //            //建立目录
        //            FileDirectoryHelper.CreateFolder(sFilePath);
        //            string reFilePath = sFilePath;//返回
        //            //路径
        //            sFilePath = System.Web.HttpContext.Current.Server.MapPath(sFilePath);
        //            string strFilePath = System.IO.Path.Combine(sFilePath, sFileName);
        //            oFile.SaveAs(strFilePath);
        //            string returntemp = reFileP + "|" + reFileName;
        //            return returntemp;
        //        }
        //        else
        //        {
        //            return null;
        //        }
        //    }
        //    catch
        //    {
        //        return null;
        //    }
        //}
        /// <summary>
        /// 上传视频 edit by yjihrp 2011.4.12
        /// </summary>
        public static string ClientUploadVideo(HttpPostedFile f)
        {
            try
            {
                // Get the uploaded file name.
                string sFileName = System.IO.Path.GetFileName(f.FileName);//原文件名
                if (sFileName != "")
                {
                    string FileTxt = System.IO.Path.GetExtension(f.FileName);//扩展名
                    string nFileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString();//当前时间
                    Random sran = new Random();//取随机数;
                    string Rand = sran.Next(1, 9).ToString();
                    sFileName = nFileName + Rand + FileTxt;//新的文件名(当前时间+1位随机数)
                    string reFileName = sFileName;//返回
                    //取保存目录
                    string sFilePath = ConfigurationManager.AppSettings["VideoUpload"];
                    //上传时间月份的文件夹(如:2007-1)
                    //edit by yjihrp 2011.4.11
                    //string reFileP = "http://flv.ipow.cn" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
                    string reFileP = "http://flv.ipow.cn" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
                    sFilePath = "~/Upload" + sFilePath + "/" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "/Source/";
                    //建立目录
                    FileDirectoryHelper.CreateFolder(sFilePath);
                    string reFilePath = sFilePath;//返回
                    //路径
                    //  sFilePath = System.Web.HttpContext.Current.Server.MapPath(sFilePath);
                    string copySFilePath = System.Web.HttpContext.Current.Server.MapPath(sFilePath);
                    string strFilePath = System.IO.Path.Combine(copySFilePath, sFileName);
                    f.SaveAs(strFilePath);

                    // edit by yjihrp 2011.4.14
                    string ffPath = System.Web.HttpContext.Current.Server.MapPath("~/Upload/flv/ffmpeg.exe");
                    FfmpegHelper ffmpeg = new FfmpegHelper(ffPath);
                    ffmpeg.ToJpg(strFilePath);
                    string catchImgFileName = System.IO.Path.ChangeExtension(reFileName, ".jpg");
                    string returntemp = reFileP + "|" + reFileName + "|" + catchImgFileName;
                    //string returntemp = reFileP + "|" + reFileName ;
                    return returntemp;
                }
                else
                {
                    return null;
                }
            }
            catch
            {
                return null;
            }
        }