怎么取出文件域浏览出来的本地路径来? 用js在没有上传之前取到FILE中的地址。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>var img=null;var diskuse = 3823643var quota = 22020096var 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> <input type=file name=FILE1 class=bg4 onChange="setTimeout('checkimage()',500)">这是校友录上面可以预览本地图片的代码 keaizhong(可爱钟)(温州的PHPER) 怎么做?能不能具体点,谢谢 <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()换成传值的语句就行了。 <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以上版本 刚刚搞错了取$_POST['save_pic'] <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>这样子就能得到文件的本地路径了。然后拿这个路径做干 别的事情,你自己来操作了。 多谢大家了!wasuka(被奴役的食尸鬼)、sumer99(新来的)、keaizhong(可爱钟)(温州的PHPER)(19801010)老大的代码都可以做到,谢谢了! GOOGLE地址API调用与GOOGLE网站的地图不一样? 一个非常好用的PHP编辑器 base64_decode为什么不正常呢? encode之前没有中文 PHP怎样读取并把EXCEL文件的批注导入到mysql里面 用什么方法能开发PHPQQ群聊天机器人? 请问phpbb是免费的吗? 问:php中将字串转为日期的函数? 用php实现将excel到入mysql中??高人快来救我 求教:网站文章系统怎么做?!!! cookie不能保存PHP中的类对象吗? 本人刚学PHP,请问怎么打开错误调试功能 require_once和require有什么区别
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>
这是校友录上面可以预览本地图片的代码
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()换成传值的语句就行了。
<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以上版本
取$_POST['save_pic']
<input type="file" name="filepath" onChange="alert(this.value)">
<INPUT TYPE="submit" name="submit">
</form>这样子就能得到文件的本地路径了。
然后拿这个路径做干 别的事情,你自己来操作了。