IE8支持type =“file”? [英] IE8 support for type="file"?

查看:142
本文介绍了IE8支持type =“file”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在显示图像的php页面中,我遇到了IE8支持< input type =file> 的问题,点击时会打开一个文件浏览器选择要上传的文件。



这适用于Firefox和Chrome,我很确定问题来自< input type =文件> 及其对IE8的支持。 IE8的结果是图像没有显示出来,如果我点击坐在图像位置的白色矩形,什么也没有发生......



这里是code:

 < div class =file_wrap> 
< input id =filetype =filename =fileonchange =sendfile(); />
< / div>

和CSS:

  .file_wrap {
background:url('icon / add.gif');
overflow:hidden;
width:116px;
height:147px;
光标:手;
}

.file_wrap input {
opacity:0;
font-size:999px;
光标:手;
}

也许你们有些人曾经遇到过吗?

解决方案

定制样式的< input type = file> 元素明确不鼓励。 p>

首先,它的默认外观在各种浏览器中完全不同(您没有提到Safari,这也使其与其他浏览器的显示截然不同)。仅此一项就很难很好地设计它。



但更重要的是,大多数浏览器主动阻止一些标准的CSS和Javascript操作与<$ c $由于potentital的安全问题,c> file 元素。



为了避免恶意脚本拦截或更改文件名以及路径。如果允许的话会发生什么的影响是相当明显的。

另外,元素通常只允许使用CSS的相当少量的样式。这是因为恶意网页正在设计元素,使其看起来不像文件元素,从而欺骗用户上传他们本不应该上传的文件。



此页面提供了有关该主题的进一步阅读,并提供了有关样式化的提示。



希望有所帮助。


I have a problem of IE8 support with <input type="file"> on a php page displaying an image, which when clicked on opens a file browser to choose a file to upload.

This works fine with Firefox and Chrome and I am pretty sure the problem comes from <input type="file"> and its support with IE8. The result on IE8 is that the image does not get displayed and that if I click on the white rectangle sitting in place of the image nothing happens...

Here is the code:

<div class="file_wrap">
   <input id="file" type="file" name="file" onchange="sendfile();" />
</div>

And the CSS:

.file_wrap {
   background: url('icon/add.gif');
   overflow:   hidden;
   width:      116px;
   height:     147px;
   cursor:     hand;
}

.file_wrap input {
   opacity:    0;
   font-size:  999px;
   cursor:     hand;
}

Maybe some of you guys came across that before?

解决方案

Custom styling of the <input type=file> element is explicitly discouraged.

Firstly, its default look and feel is completely different across the various browsers (you didn't mention Safari, which also renders it very differently from the other browsers). This alone would make it quite hard to style it nicely.

But more importantly, most browsers actively prevent a number of standard CSS and Javascript actions from working with file elements, because of potentital security issues.

Some Javascript is prevented in order to avoid malicious scripts from intercepting or changing the filename and path. The implications of what could happen if this were allowed are fairly obvious.

In addition, the element generally only allows a fairly minimal amount of styling using CSS. This is because malicious pages were styling the element to make it look less like a file element, and thereby tricking users into uploading files that they shouldn't have been uploading.

This page provides further reading on the subject, and gives tips on styling it successfully.

Hope that helps.

这篇关于IE8支持type =“file”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆