Ejemplo n.º 1
0
    public string UploadPhoto()
    {
        string result;

        try
        {
            if (FupPhoto.HasFile)
            {
                ImageProcess img       = new ImageProcess();
                Stream       imgStream = FupPhoto.FileContent;

                //validates if file is a valid JPG/PNG image
                bool isValidType = img.ValidateImageFileType(imgStream);
                //validates if file meets valid size;
                bool isValidSize = img.ValidateImageFileSize(imgStream, 1048576);


                if (isValidType == false)
                {
                    return("invalid");
                }
                if (isValidSize == false)
                {
                    return("large");
                }

                string FileExtension = Path.GetExtension(FupPhoto.FileName).ToLower();
                string NewFileName   = "Tenant_" + StringCustomizers.dateStampNoID + FileExtension;

                FupPhoto.SaveAs(Server.MapPath(@"~/uploads/" + NewFileName));
                result = NewFileName;
            }
            else
            {
                result = "nofile";
            }
        }
        catch (Exception ex)
        {
            result = "error: " + ex.Message;
        }
        finally
        {
            FupPhoto.Dispose();
        }
        return(result);
    }
Ejemplo n.º 2
0
        protected void BtnConfirm_Click(object sender, EventArgs e)
        {
            string pid = Request.QueryString["ProblemID"];

            //FupPhoto
            //判断是否有待上船的文件
            if (FupPhoto.HasFile)
            {
                //设置文件保存的路径
                string strPath = Server.MapPath("~/upload/recheckPhoto/") + Guid.NewGuid().ToString("N") + FupPhoto.FileName;
                //
                //保存文件
                FupPhoto.SaveAs(strPath);

                //pid
                RoadSolution.BLL.Problem   problemBll = new RoadSolution.BLL.Problem();
                RoadSolution.Model.Problem problem    = problemBll.GetModel(pid);
                problem.ReviewShot = strPath;
                problemBll.Update(problem);
            }
        }