Läuft auf IE,Opera,FF
Code:
<html>
<head>
<title>Upload CSS</title>
<style type="text/css">
#ausrichtung{
margin:0px 0px 0px 80px;
border:1px solid red;
width:400px;
height:200px;
}
div.uploader {
position: relative;
width: 95px;
height: 20px;
overflow: hidden;
margin:0px 0x 0px 70px;
}
input.uploadbox {
position: absolute;
right: 0;
font-size: 30px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity: 0);
}
div.uploader_img {
background: transparent url(test.gif) no-repeat;/* Grösse des Gifs (BxL: 95x20)*/
white-space: normal;
width: 95px;
height:20px;
}
#uploadausgabe{
width:200px;
height:100px;
border:1px solid gray;
}
</style>
<script type="text/javascript">
var fileCheck;
var uploadNamePosition;
var uploadName;
function UploadFile(wert) {
fileCheck = wert.lastIndexOf('/');
if(fileCheck==-1){
//
uploadNamePosition = wert.lastIndexOf('\\')+1;
}
else{
uploadNamePosition = wert.lastIndexOf('/')+1;
}
//
// Extrahiere Dateinamen vom übrigen Pfad
uploadName = wert.slice(uploadNamePosition,wert.length);
//
// Ausgabe des Upload Dateinamens
document.getElementById("uploadausgabe").innerHTML = "Dateiname ist:"+uploadName;
}
</script>
</head>
<body>
<div id="ausrichtung">UploadFile
<div class="uploader">
<input class="uploadbox" type="file" onchange="UploadFile(this.value)" />
<div class="uploader_img"></div>
</div>
<div id="uploadausgabe"></div>
</div>
</body>
</html>