js关于图片上传路径的获取

js关于图片上传路径的获取,第1张

给你个简单的例子,很多张的话判断是否是新的只能通过文件名了:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 40 Transitional//EN">

<HTML>

<HEAD>

<TITLE> New Document </TITLE>

<META NAME="Generator" CONTENT="EditPlus">

<META NAME="Author" CONTENT="">

<META name="keywords" content="路径,相对于,你是,相关内容,图片上传">

<META name="description" content="给你个简单的例子,很多张的话判断是否是新的只能通过文件名了:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 40 Transitional//EN"><HTML>&">

<script>

function yulan()

{

var fileext=documentform1UpFilevaluesubstring(documentform1UpFilevaluelastIndexOf(""),documentform1UpFilevaluelength);

fileext=fileexttoLowerCase();

if ((fileext!='jpg')&&(fileext!='gif')&&(fileext!='jpeg')&&(fileext!='png')&&(fileext!='bmp'))

{

alert("对不起,系统仅支持标准格式的照片,请您调整格式后重新上传,谢谢 !");

documentform1UpFilefocus();

}

else

{

//alert(''+documentform1UpFilevalue);

documentgetElementById("preview")innerHTML="预览区<img src='"+documentform1UpFilevalue+"' style='border:6px double #ccc';padding:5px;>"

}

}

</script>

<style>

#preview{

border: 1px dashed #F00;

width:200px;

height:200px

}

</style>

</HEAD>

<BODY>

上传前御览

<form name="form1" method="POST" enctype="multipart/form-data">

<input type="file" name="UpFile" size="46" onchange="yulan()">

<div id="preview">预览区</div>

</form>

</BODY>

</HTML>

'从内容中提取的src

Function RegExp_Execute(strng)

Dim regEx, Match, Matches,values '建立变量。

Set regEx = New RegExp '建立正则表达式。

regExPattern = "src\=+\(gif|jpg)" '设置模式。

regExIgnoreCase = true '设置是否区分字符大小写。

regExGlobal = True '设置全局可用性。

Set Matches = regExExecute(strng) '执行搜索。

For Each Match in Matches '遍历匹配集合。

values=values&MatchValue&""","

Next

RegExp_Execute = values

End Function

%>

<%

str="图文新闻<IMG src=""/UploadFiles/20081027jpg"" border=0>下一张<IMG src=""/UploadFiles/06gif"">"

aa=RegExp_Execute(str)

responsewrite replace(aa,"src=","")

%>

//先得到

var

img=documentgetElementById("的id");

//得到路径

var

path=imgsrc;

//从路径中截取名[包括后缀名]

var

filename;

if(pathindexOf("/")>0)//如果包含有"/"号

从最后一个"/"号+1的位置开始截取字符串

{

filename=pathsubstring(pathlastIndexOf("/")+1,pathlength);

}

else

{

filename=path;

}

你是相对于 它所在的上级的位置,还是整个页面?

可以用jquery

<div id="xxx"></div>

js:

var o =$("#xx")offset();// { left:0,top:0 },这个是相对于上级的

var o =$("#xx")position();//同上,这是相对于整个页面的

var i_strngth = 1;

var i_image = 0;

var imageurl = new Array();

// 这一部分我是手功指定的路径,你的路径是放在数据库中的,只用在这里做更改,把路径的设置改成动态读取就可以了

//======================================

imageurl[0] ="images/pic1gif";

imageurl[1] ="images/pic2gif";

imageurl[2] ="images/pic3gif";

imageurl[3] ="images/pic4gif";

//======================================

function showimage()

{

if(documentall)

{

if (i_strngth <= 110)

{

div_PicinnerHTML = "<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(documentlayers)

{

clearTimeout(timer)

documentdiv_Picdocumentwrite("<img src='" + imageurl[i_image] + "' border='0' style='height:248px; width:138px;' />");

documentclose();

i_image++;

if (i_image >= imageurllength)

{

i_image = 0;

}

var timer = setTimeout("showimage()", 2000);

}

}

function hideimage()

{

if (i_strngth >= -10)

{

div_PicinnerHTML = "<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 >= imageurllength)

{

i_image = 0;

}

i_strngth = 1;

var timer=setTimeout("showimage()", 500);

}

}

那就需要用到Ajax技术,你是用时间来做为名称,那么可以用程序取出文件名然后选取离系统当前时间最近的一个文件做为当前显示的,然后回传达到JS来进行路径的更改显示

以上就是关于js关于图片上传路径的获取全部的内容,包括:js关于图片上传路径的获取、ASP JS 获取文章图片路径、js 怎么截取img路径里的图片名等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9719472.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-01
下一篇2023-05-01

发表评论

登录后才能评论

评论列表(0条)

    保存