用javascript就可以搞定了:
function showsize()
{
document.upload.FILE1.value = trim(document.upload.FILE1.value);
document.all.view.src = document.upload.FILE1.value;
//alert(document.all.view.height + "x" + document.all.view.width + " -> " + document.all.view.fileSize);
var diskuse = 6255309
var quota = 20971520
        var maxfilesize = 2097152;
        var showimg = new Image();
        showimg.src = document.upload.FILE1.value;
        if(showimg.fileSize>0) 
{
if(showimg.fileSize > maxfilesize)
{
alertmsg = "您选中的图片大于" + maxfilesize+ ",目前字节数=" + showimg.fileSize;
return false;
} if(showimg.width > 500)
{
var ori_w= showimg.width;
var ori_h = showimg.height;
showimg.width = 500;
showimg.height = ori_h * showimg.width / ori_w;
} if(showimg.width < 5 || showimg.height <5)
{
showimg.width = showimg.height = 150;
} //document.all.view.src = showimg.src;
document.all.view.style.width = showimg.width;
document.all.view.style.height = showimg.height;
checkShowSize = true;
return true;
} else if(loadNum<loadTimes) {
loadNum ++ ;
setTimeout('showsize()',500);
} else if(loadNum>=loadTimes){
loadNum = 0;
//alertmsg = "图片字节数=0,请换张图片上传";
alertmsg = "图片预览失败,请重新上传";
return false;
}
}

解决方案 »

  1.   

    如果利用mySmartUpload,他自带了一个读取文件大小的函数。Size=myFile.getSize();或者用上面那个程序也行
      

  2.   


    var maxfilesize = 20971;var showimg = new Image();
            showimg.src = document.upload.FILE1.value;
            if(showimg.fileSize>0) 
    {
    if(showimg.fileSize > maxfilesize)
    {
    alertmsg = "您选中的图片大于" + maxfilesize+ ",目前字节数=" + showimg.fileSize;
                                alert("您的图片介绍超过32字,目前字数="+showimg.fileSize);
    return false;
    }
      

  3.   

    <input type=file name=FILE1 onChange="setTimeout('showsize()',500)">
      

  4.   

    这个问题俺问过,好像必须上传之后才能得到。郁闷ing……
      

  5.   

    用 jspsmartupload不就解决了!!!
    那东东可好用了