保存后,PHP imagejpeg强制打开文件

时间:2017-09-07 17:31:04

标签: php imagejpeg

我试图制作上传图片的简单代码>调整大小>保存在目录中>并在调整大小后显示在浏览器中。 问题是文件正在保存但我的回声没有工作,我得到灰色背景信息,图像包含错误,无法显示。

当imagejpeg参数设置为imagejpeg($ imageP,null,100)时,图片会显示在此灰色背景上,但页面的其余部分仍然缺失。

调整功能:

  public class MainPageViewModel
    {
        public MainPageViewModel()
        {            
            Profession1 = new Person();
            Profession2 = new Person();                      
          private Person profession1;

        public Person Profession1
        {
            get { return profession1; }
            set { this.profession1 = value; }
        }

        private Person profession2;

        public Person Profession2
        {
            get { return profession2; }
            set { this.profession2 = value; }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

    }

    public class Person : INotifyPropertyChanged
    {
        public Person()
        {
            _professions = new List<string>();
            _professions.Add("Lawyer");
            _professions.Add("Politician");
            _professions.Add("Other");         
        }

        private string _profession;
        public string Profession
        {
            get
            {
                if (string.IsNullOrWhiteSpace(_profession))
                {
                    // _profession = _professions.LastOrDefault();
                }
                return _profession;
            }
            set
            {
                if (_profession != value)
                {
                    _profession = value;
                    NotifyPropertyChanged("Profession");
                }
            }
        }      

        private List<string> _professions;

        public List<string> Professions
        {
            get
            {
                return _professions;
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }   

代码:

public sealed partial class MainPage : Page
    {
        Binding binding;
        public MainPage()
        {
            this.InitializeComponent();
            var datacontent = (this.Resources["datacontent"] as MainPageViewModel);
            this.UpdateBinding1(this.contentControl, datacontent);
        }         

        public void UpdateBinding1(FrameworkElement contentcontrol, object datacontext)
        {
            binding = new Binding();
            binding.Path = new PropertyPath("Profession1");
            binding.Mode = BindingMode.TwoWay;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            binding.Source = datacontext;  // view model
            BindingOperations.SetBinding(contentcontrol, ContentControl.ContentProperty, binding);
        }

        public void UpdateBinding(FrameworkElement contentcontrol, object datacontext)
        {
            binding = new Binding();
            binding.Path = new PropertyPath("Profession2");
            binding.Mode = BindingMode.TwoWay;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            binding.Source = datacontext;  // view model
            BindingOperations.SetBinding(contentcontrol, ContentControl.ContentProperty, binding);
        }

       private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var datacontext = (this.Resources["datacontent"] as MainPageViewModel);
            this.UpdateBinding(this.contentControl,datacontext);
        }
}

chmod和chow已配置。 希望有人可以帮我解决我的第一个问题,欢呼。

0 个答案:

没有答案