我想用JS获取待上传文件的大小,
              var image = new Image();
              image.dynsrc = src;
              alert(image.fileSize);
但IE8下提示dynsrc属性拒绝访问,请问如何解决,有没有别的方法啊?

解决方案 »

  1.   

    你可以使用swf,silverlight,File Api获得,你的 这种方法由于安全性问题现在不能使用了
      

  2.   

    能不能麻烦您说的详细点,最好能举个例子,silverlight我没接触过
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;namespace SilverlightApplication1
    {
      public partial class MainPage : UserControl
      {
        public MainPage()
        {
          InitializeComponent();
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
          OpenFileDialog openFileDialog1 = new OpenFileDialog();
          openFileDialog1.Filter = "All files (*.*)|*.*";
          openFileDialog1.Multiselect = false;
          bool? userClickedOK = openFileDialog1.ShowDialog();
          if (userClickedOK == true)
          {
            System.IO.Stream fileStream = openFileDialog1.File.OpenRead();
            MessageBox.Show(fileStream.Length.ToString());
            fileStream.Close();
          }
          openFileDialog1 = null;
        }    
      }
    }
      

  4.   

    Flash上传限制文件大小
    http://demo.swfupload.org/Documentation/File API得到文件大小
    http://dotnet.aspx.cc/article/facbb9a7-c9c6-46ad-9591-5ba34ae27e58/read.aspx