您的位置:首页 > 其它

直接获取上传文件的input值

2015-06-08 11:57 281 查看
js函数
<script>

function m(i){

var url=i.value;

url=url.split("\\");

var n = url[url.length-1];

n = n.substring(0,n.lastIndexOf('.'));

document.getElementById('title').value = n;

}

</script>

[/code]
资质描述<input type="text" name="ztitle" id="title"><br>

资质上传<input type="file" name="zzfile" onChange="m(this)"><br>

[/code]把资质上传的文件名直接填写在资质描述中
<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>无标题文档</title>

</head>

<body>

<h1>企业荣誉资质</h1>

<form action="zzsave.php" method="post" enctype="multipart/form-data">

类别:<select name="cname">


<?php

include '../inc/db_mysqli.php';

$rows=query('hnsc_zzclass');

foreach($rows as $v){

printf("<option value='%s'>%s</option>",$v[0],$v[0]);

}

?>


</select>

<button onClick="location.href='zzclassadmin.php';">新增类别</button><br>

资质描述<input type="text" name="ztitle" id="title"><br>

资质上传<input type="file" name="zzfile" onChange="m(this)"><br>

是否在网站上显示

<label><input type="radio" name="flag" value="y" checked>显示</label>

<label><input type="radio" name="flag" value="n">不显示</label><br>

<input type="submit" value="提交">

<script>

function m(i){

var url=i.value;

url=url.split("\\");

var n = url[url.length-1];

n = n.substring(0,n.lastIndexOf('.'));

document.getElementById('title').value = n;

}

</script>


</form>

</body>

</html>

[/code]


来自为知笔记(Wiz)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: