$image = $request->file('image');
获取的值是空的
前端代码是这样的
<tr class="tr_photo">
<td class="photo_left">请上传考生照片</td>
<td class="right_photo">
<input type="file" name="image" id="image" class="inputfile" onChange="changepic(this)"/>
<img src="" id="show" />
<label for="image" class="btn_success">选择照片</label>
</td>
</tr>
js代码是这样的
function changepic(obj){
var newsrc = getObjectURL(obj.files[0]);
document.getElementById("show").src = newsrc;
}
function getObjectURL(image){
var url = null;
if (window.createObjectURL!=undefined) { // basic
url = window.createObjectURL(image) ;
} else if (window.URL!=undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(image) ;
} else if (window.webkitURL!=undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(image) ;
}
return url ;
}
获取的值是空的
前端代码是这样的
<tr class="tr_photo">
<td class="photo_left">请上传考生照片</td>
<td class="right_photo">
<input type="file" name="image" id="image" class="inputfile" onChange="changepic(this)"/>
<img src="" id="show" />
<label for="image" class="btn_success">选择照片</label>
</td>
</tr>
js代码是这样的
function changepic(obj){
var newsrc = getObjectURL(obj.files[0]);
document.getElementById("show").src = newsrc;
}
function getObjectURL(image){
var url = null;
if (window.createObjectURL!=undefined) { // basic
url = window.createObjectURL(image) ;
} else if (window.URL!=undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(image) ;
} else if (window.webkitURL!=undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(image) ;
}
return url ;
}
解决方案 »
- window.onload执行带参数的函数
- enter按钮事件如何把按钮转到easyui的combobox,datetimebox等事件上去啊?
- 进入一个页面后 自动刷新一次的js代码如何写
- 请问如何遍历得到本地对象如String,Boolean的属性和方法
- 如何取得超链接文字的中心点
- 关于||运算符的问题?????????????????????????
- 功能很好的页面,如何实现的?有源码吗
- 关于ie快捷按钮的使用问题,急急急!!!
- 请问如何在一个JavaScript函数中调用另一段asp程序?
- 怎么在用户验证失败时,弹出一个alert,然后关闭或刷新原窗口。急
- 如何使自己页面展现出用户搜索哪个关键词
- 一个小js问题,绑定快捷键F8
如果用form提交的话,看下提交类型有没有设置对,`<form enctype="multipart/form-data">`