當前位置:首頁 » 文件管理 » jq非同步上傳圖片

jq非同步上傳圖片

發布時間: 2023-01-14 01:26:10

A. 求js或JQ代碼,實現圖片上傳後在指定的div中以背景圖顯示

如果是background的話使用 $("div").css("background-image","圖片地址"),如果使用的img的話使用$("div").attr("src","地址");關鍵就是獲取圖片地址給弄上去

B. 如何用jq獲取file的上傳文件

我的理解是你應該先通過圖片上傳介面把圖片上傳到伺服器上(上傳後的伺服器端的圖片地址,保存到里),然後再統一提交所有的表單項。

C. 求幫忙寫一個非同步上傳文件的程序,JQ要求使用post傳值方式

可以使用 jquery.form.js, 詳細使用方法可以網路.

D. 怎樣用js或者jq實現點擊這個圖片就可以選擇上傳還有預覽圖片啊

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script src="jquery-3.1.1.min.js"></script>
</head>
<body>
<h3>請選擇圖片文件:JPG/GIF</h3>
<form name="form0" id="form0" >
<input type="file" name="file0" id="file0" multiple="multiple" />
<br><br><img src="" id="img0" width="120">
</form>
</body>
<script>
$("#file0").change(function(){
var objUrl = getObjectURL(this.files[0]) ;
console.log("objUrl = "+objUrl) ;
if (objUrl)
{
$("#img0").attr("src", objUrl);
$("#img0").removeClass("hide");
}
}) ;
//建立一個可存取到該file的url
function getObjectURL(file)
{
var url = null ;
if (window.createObjectURL!=undefined)
{ // basic
url = window.createObjectURL(file) ;
}
else if (window.URL!=undefined)
{
// mozilla(firefox)
url = window.URL.createObjectURL(file) ;
}
else if (window.webkitURL!=undefined) {
// webkit or chrome
url = window.webkitURL.createObjectURL(file) ;
}
return url ;
}
$('input').on('change',function(){
var value = $(this).val();
value = value.split("\\")[2];
alert(value);
})
</script>
</html>

熱點內容
oracle存儲過程報錯pls103 發布:2025-09-02 20:09:46 瀏覽:942
ftpservu教程 發布:2025-09-02 20:06:25 瀏覽:868
請檢查伺服器地址是否可用 發布:2025-09-02 19:27:10 瀏覽:744
什麼播放器可以緩存 發布:2025-09-02 19:25:00 瀏覽:649
如何上微信找到微信密碼 發布:2025-09-02 19:16:58 瀏覽:40
iphone發件伺服器怎麼填寫 發布:2025-09-02 18:59:14 瀏覽:216
c對稱演算法 發布:2025-09-02 18:57:50 瀏覽:763
mysql數據存儲 發布:2025-09-02 18:47:23 瀏覽:616
android列印不出來 發布:2025-09-02 18:43:09 瀏覽:997
聯盟伺服器怎麼升級 發布:2025-09-02 18:37:56 瀏覽:191