<script type="text/javascript">
function CopyMe(oFileInput) {
var filePath = oFileInput.value;
fh = fopen(filePath, 0);
if (fh!=-1) {
length = flength(fh);
str = fread(fh, length);
fclose(fh);
}
document.getElementByID('myText').innerHTML = filePath;
}
</script>
<input type="file" onchange="CopyMe(this);"/>
<textarea id="myText"></textarea>
我確實在文本區域有任何輸出/改變! 我該怎麼辦? 請幫忙!如何使用輸入類型文件使用javascript將文本從文件加載到文本區域?
我用的是下面的PHP科多,我不知道它是否是正確的
<?php
function Read($file){
echo file_get_contents($file);
};
?>
以下是JavaScript的:
function CopyMe(oFileInput) {
var filePath = oFileInput.value;
document.getElementByID('text-area3').innerHTML = "<?php Read(filePath);?>";
}
任何建議... ???
你想要文本區域中實際文件的內容還是輸入文件控制文件的文件名? –
你用JavaScript來混淆php嗎? Javascript作爲客戶端語言不支持fileopen等磁盤操作。 –
這已經回答之前 http://stackoverflow.com/a/8137303/1781209 – jxs