用js在没有上传之前取到FILE中的地址。

解决方案 »

  1.   

    <script>
    var  img=null;
    var diskuse = 3823643
    var quota = 22020096
    var maxfilesize = 1048576;function  checkimage(){
    //setTimeout('function wait(){}',5000);
    document.upload.FILE1.value = trim(document.upload.FILE1.value);
    var name = document.upload.FILE1.value;
    if(/^.+\.(gif|jpg|png)$/i.test(name)){
    if(img)img.removeNode(true);
    img=document.createElement("img");
    img.style.position="absolute";
    img.style.visibility="hidden";
    img.attachEvent("onerror",ErrImgType);
    img.attachEvent("onreadystatechange",ErrImgBig);
    document.body.insertAdjacentElement("beforeend",img);
    img.src=name; var showimg_width = img.width;
    var showimg_height = img.height; 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 < 50 && showimg_height <50)
    {
    showimg_width = showimg_height = 150;
    } document.all.view.src = name;
    document.all.view.style.width = showimg_width;
    document.all.view.style.height = showimg_height; }
    else{ErrImgType()}
    }function  ErrImgType(){
    upload.reset();
    alert("上传图片文件类型只能是jpg或gif!");
    return false;
    }function  ErrImgBig(){
    if  (img.fileSize>maxfilesize){
    upload.reset();
    alert("文件大小不能超过1M字节!");
    return false;
    }
    }function picsubmit() {
    document.upload.PICINTRO.value = trim(document.upload.PICINTRO.value);
    if(document.upload.PICINTRO.value.length>32) {
    alert("您的图片介绍超过32字,目前字数="+upload.PICINTRO.value.length);
    return false; 
    } filename = document.upload.FILE1.value.toLowerCase();
    filext = filename.substring(filename.length-3,filename.length); 
    if(filext!="jpg" &&  filext!="gif") {
    alert("您上传的图片不是jpg或gif格式");
    return false;
    }

    if(document.upload.share2school.checked) {
    document.upload.STATUS.value = 11;
    } else { document.upload.STATUS.value = 1;}
    var str_cid = -1;
    HaveCid = false;
    if(document.upload.share2otheralbum.value==1) {
    if (document.upload.chkid != undefined) {
    if(document.upload.chkid.length==1 || document.upload.chkid.length == undefined) {
    if(document.upload.chkid.checked)
    str_cid = document.upload.chkid.value + ",";
    } else {
    str_cid = "";
    //alert(document.upload.chkid.length);
    for(i=0;i<document.upload.chkid.length;i++) {
    if(document.upload.chkid[i].checked)  { 
    str_cid +=document.upload.chkid[i].value + ",";
    HaveCid = true;
    }
    }
    if(!HaveCid) str_cid = -1;
    }
    }
    }
    document.upload.share2otheralbumID.value = str_cid;
    //alert(document.upload.share2otheralbumID.value);
    document.all.sending0.style.display = "none";
    document.all.sending2.style.visibility="visible";
    return true;
    }
    </script>
      

  2.   

    <input type=file name=FILE1 class=bg4 onChange="setTimeout('checkimage()',500)">
    这是校友录上面可以预览本地图片的代码
      

  3.   

    keaizhong(可爱钟)(温州的PHPER) 怎么做?能不能具体点,谢谢
      

  4.   

    <script language="javascript">
    function GetName()
    {
      alert(f.photo.value)
    }
    </script><form name="f" enctype="multipart/form-data" onsubmit="GetName()">
    <input type="file" name="photo">
    <input type="submit">
    </form>
    马马虎虎写的,未经过测试。
    你把alert()换成传值的语句就行了。
      

  5.   


    <form name="form1" enctype="multipart/form-data" method="post" action="">
     <input name="imagename" type="file" size="50" onpropertychange="document.all.save_pic.value='file:///'+this.value">
    <input type="hidden" name="save_pic" value="">
      <INPUT TYPE="submit" name="submit">
     </form>取$_POST['imagename'] 用于php4.0以上版本
      

  6.   

    刚刚搞错了
    取$_POST['save_pic']
      

  7.   

    <form name="form1" enctype="multipart/form-data" method="post" action="">
      <input type="file" name="filepath" onChange="alert(this.value)">
      <INPUT TYPE="submit" name="submit">
    </form>这样子就能得到文件的本地路径了。
    然后拿这个路径做干 别的事情,你自己来操作了。
      

  8.   

    多谢大家了!wasuka(被奴役的食尸鬼)、sumer99(新来的)、keaizhong(可爱钟)(温州的PHPER)(19801010)老大的代码都可以做到,谢谢了!