導航:首頁 > 文件目錄 > js文件獲取圖片

js文件獲取圖片

發布時間:2022-01-21 14:00:14

javascript 中怎樣獲取file里的完整路徑,如:D:\E\1.jpg

樓主問的應該是獲取一個file input表單域的文件名全路徑吧,這是不能實現的,除非在IE6下面。這個已經因為安全問題被現代所有瀏覽器屏蔽了,只能獲取到文件名

js獲取的src圖片 怎麼才能獲取到jqimg

直接用JQ. 引入JQ核心文件

用$('img').attr('jqimg');
attr('')想獲取什麽屬性就寫什麽

㈢ 如何用js怎麼獲取到圖片的相對路徑

javascript中img.src屬性可以獲取到圖片的完整路徑, 相對路徑要通過與相對位置計算得出。計算方版法:
先要明權確自己的相對位置在哪,這個是需要人為指定的。
核心代碼如下:
var res=document.getElementById("img").src;
var root_href='根目錄路徑';
res=document.getElementById("img").src.replace(root_href,'');
用jquery方法
var res=$("#img").attr("src");
res=res.substring(res.indexOf("根")+2);
更多關於在上傳文件的過程得到完整路徑的方法請參考如下:
file.select();
var res=document.selection.createRange().text;
var res=file.files.item(0).getAsDataURL();
var res=file.value

㈣ javascript中怎樣讀取指定文件夾里的圖片

var i_strngth = 1;
var i_image = 0;
var imageurl = new Array();
// 這一部分我是手功指定的圖片路徑,你的圖片路徑是放在資料庫中的,只用在這里做更改,把路徑的設置改成動態讀取就可以了
//======================================
imageurl[0] ="images/pic1.gif";
imageurl[1] ="images/pic2.gif";
imageurl[2] ="images/pic3.gif";
imageurl[3] ="images/pic4.gif";
//======================================
function showimage()
{
if(document.all)
{
if (i_strngth <= 110)
{
div_Pic.innerHTML = "<img style=\"filter:alpha(opacity='" + i_strngth + "'); height:248px; width:138px;\" src='" + imageurl[i_image] + "' border='0' />";
i_strngth = i_strngth + 10;
var timer=setTimeout("showimage()", 100);
}
else
{
clearTimeout(timer);
var timer = setTimeout("hideimage()", 1000);
}
}
if(document.layers)
{
clearTimeout(timer)
document.div_Pic.document.write("<img src='" + imageurl[i_image] + "' border='0' style='height:248px; width:138px;' />");
document.close();
i_image++;
if (i_image >= imageurl.length)
{
i_image = 0;
}
var timer = setTimeout("showimage()", 2000);
}
}
function hideimage()
{
if (i_strngth >= -10)
{
div_Pic.innerHTML = "<img style=\"filter:alpha(opacity='" + i_strngth + "'); height:248px; width:138px;\" src='" + imageurl[i_image] + "' border='0' />";
i_strngth = i_strngth - 10;
var timer = setTimeout("hideimage()", 100);
}
else
{
clearTimeout(timer)
i_image++;
if (i_image >= imageurl.length)
{
i_image = 0;
}
i_strngth = 1;
var timer=setTimeout("showimage()", 500);
}
}
那就需要用到Ajax技術,你是用時間來做為圖片名稱,那麼可以用程序取出文件名然後選取離系統當前時間最近的一個文件做為當前顯示的圖片,然後回傳達到JS來進行圖片路徑的更改顯示

㈤ 如何用JS/jQuery獲取file裡面圖片的 寬高!求大神~

高級瀏覽器,為了安全考慮,input file的信息是不可訪問的.
可以考慮上傳伺服器,讓後台計算.

㈥ js 中,已知圖片路徑,怎麼獲取圖片的大小,不是寬高,是大小(多少k那種)

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>

<input type="file" id="fs" onchange="getFileSize()"/>
</body>

<script type="text/javascript">

function getFileSize(){ var file = document.getElementById("fs"); var size = file.files[0].size;
alert(size);
} </script>
</html>

㈦ js 獲取圖片並下載到本地

獲取到本地是緩存到ie的緩存中(緩存文件中可以查看到)的,使用fso控制文件是有安全上的問題的。建議不要用fso

㈧ js或jquery獲取文件夾裡面今天的圖片,該如何寫

這個是不能直接獲取到,你需要藉助後端的語言,通過後端的語言獲取文件,返還給JS,通過AJAX實現

㈨ javascript從一個文件夾中根據圖片名稱讀取圖片,並在body里顯示這個圖片

<scripttype="text/javascript">
vararr=["201310210930.jpg","201310210945.jpg","20110945.jpg","201610210945.jpg"];
functionmaxTime(arr){
varstr='',maxIndex=0;
for(vari=0,l=arr.length;i<l;i++){
屬str=arr[maxIndex].substring(0,arr[maxIndex].indexOf("."));
str1=arr[i].substring(0,arr[i].indexOf("."));
if(parseInt(str)<parseInt(str1)){
maxIndex=i;
}
}
returnarr[maxIndex];

}
alert(maxTime(arr))//201610210945.jpg;
</script>

㈩ 如何在JS中獲取圖片的像素

方法一:獲取圖片的寬高。可以用offsetWidth和offsetHeight;

方法二:

  1. 你先獲取img標簽標簽元素。用getElementById()或者getElementsByClassName或者getElementsByTagName()都可以。

  2. 獲取之後,如果你的img圖片有width和height 屬性,可以直接用img元素對象點屬性

document.getElementsByTagName("img")[0].width;

document.getElementsByTagName("img")[0].height;

3.如果img元素本身沒有width和height屬性。你可以獲取img元素的style樣式

functiongetStyle(obj,attr){

returnobj.currentStyle?obj.currentStyle[attr]:getComputedStyle(obj)[attr];

};

obj是你的img標簽對象,attr是你的想要獲取的屬性;

currentStyle支持IE低版本瀏覽器,

getComputedStyle支持主流瀏覽器

閱讀全文

與js文件獲取圖片相關的資料

熱點內容
中文影院在線 瀏覽:108
可編程式控制制器控制什麼 瀏覽:320
iphone取消阻止來電後 瀏覽:590
asp接收form表單上傳文件 瀏覽:437
用手機共享電腦網路 瀏覽:696
電腦文件路徑前綴 瀏覽:811
游戲編程都需要學哪些軟體下載 瀏覽:357
組成合同文件內容 瀏覽:895
黑寡婦燈光配置文件 瀏覽:833
前戲電影 瀏覽:668
linuxwgetcurl 瀏覽:636
河東區愛琴海影院影訊 瀏覽:601
反映女中介和客戶的台灣電影 瀏覽:341
網路技術專業前景 瀏覽:108
韓國古裝電影 床戲 瀏覽:933
哈薩克電影全集免費 瀏覽:405
韓國電影比尿尿尿的遠 瀏覽:340
一部悲傷的電影用英語怎麼說 瀏覽:303
大數據的論壇有哪些 瀏覽:854
筆記本沒網路怎麼上網 瀏覽:518

友情鏈接