编辑器上传图片路径问题

huanqiweb 2012-08-21 11:52:57
<IMG src="http://www.zhenghangplc.com/uploadfiles/201282111533867627.jpg">
这是通过编辑器上传图片路径

但是中间少了一个文件夹
<IMG src="http://www.zhenghangplc.com/adminkk/uploadfiles/201282111533867627.jpg">
这样才对,



下面是图片上传的JS代码,麻烦问一下那里出错了。
<script language="JavaScript">
<!--
window.isIE = (navigator.appName == "Microsoft Internet Explorer");
if(window.isIE) {
if(navigator.userAgent.indexOf("Opera")>-1) window.isIE = null;
}
else {
if(navigator.userAgent.indexOf("Gecko")==-1) window.isIE = null;
}
function $(sID) {
return document.getElementById(sID);
}
function adjustDialog(){
var w = $("tabDialogSize").offsetWidth + 6;
var h = $("tabDialogSize").offsetHeight + 25;
window.dialogLeft = (screen.availWidth - w) / 2;
window.dialogTop = (screen.availHeight - h) / 2;
}
window.onload = init;
function init () {
adjustDialog();
$("imgpath").select();
}
function chk_imgpath () {
var editor = window.dialogArguments.EDiaryEditor;
var oRTE = editor.iframe.contentWindow;
if($("imgpath").value == "http://" || $("imgpath").value == "") {
window.close();
return;
}
var html = "<img src='" + $("imgpath").value + "'>";
if(window.isIE) {
try{
oRTE.focus();
var oRng = oRTE.document.selection.createRange();
oRng.pasteHTML(html);
oRng.collapse(false);
oRng.select();
}
catch(e){}
}
else {
editor.runCMD('insertHTML', html);
}
window.close();
}
document.onkeydown = function (el) {
var event = window.event || el;
if(event.keyCode == 13) {
chk_imgpath();
}
}
//-->
</script>
...全文
243 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
huanqiweb 2012-08-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

浏览器上传估计返回的地址只是uploadfiles/201282111533867627.jpg
所以要检查上传返回的地址
[/Quote]
是的,我也反复调试地文件路径,但都出错,应该是代码那出错了,相关文件有editor.js resurm_upfile.asp(图片上传)
  • 打赏
  • 举报
回复
浏览器上传估计返回的地址只是uploadfiles/201282111533867627.jpg
所以要检查上传返回的地址
  • 打赏
  • 举报
回复
那你自己加上那个不就对了?
window.parent.document.getElementById('imgpath').value='adminkk/"&FileName&"';
huanqiweb 2012-08-21
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]

response.write("<script>alert('"&FileName&"');window.parent.document.getElementById('imgpath').value='"&FileName&"';window.parent.chk_imgpath();</script>")
改红色部分就可以知道返回的路径是什么了
如果返回/……
[/Quote]
返回的路径是第二种,错的。
uploadfiles/201282111533867627.jpg
huanqiweb 2012-08-21
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]

response.write("<script>alert('"&FileName&"');window.parent.document.getElementById('imgpath').value='"&FileName&"';window.parent.chk_imgpath();</script>")
改红色部分就可以知道返回的路径是什么了
如果返回/……
[/Quote]

返回的路径是:
uploadfiles/201282111533867627.jpg
错的。
  • 打赏
  • 举报
回复
response.write("<script>alert('"&FileName&"');window.parent.document.getElementById('imgpath').value='"&FileName&"';window.parent.chk_imgpath();</script>")
改红色部分就可以知道返回的路径是什么了
如果返回/adminkk/uploadfiles/201282111533867627.jpg就对
如果返回uploadfiles/201282111533867627.jpg就错
huanqiweb 2012-08-21
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]
response.write("<script>window.parent.document.getElementById('imgpath').value='"&FileName&"';window.parent.chk_imgpath();</script>")
里的
FileName
你看这个返回的值对不对吧
[/Quote]


哥们,方便留个QQ吗,帮忙改一下,实在是弄不懂。
  • 打赏
  • 举报
回复

response.write("<script>window.parent.document.getElementById('imgpath').value='"&FileName&"';window.parent.chk_imgpath();</script>")
里的
FileName
你看这个返回的值对不对吧
huanqiweb 2012-08-21
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

resurm_upfile.asp查看这个文件,最后返回的值是什么..该怎么改就怎么改.
[/Quote]


resurm_upfile.asp文件
<%
On Error Resume Next
set upload=new upload_file
if upload.form("act")="uploadfile" then
filepath=trim(upload.form("filepath"))
filelx=trim(upload.form("filelx"))

i=0
for each formName in upload.File
set file=upload.File(formName)

fileExt=lcase(file.FileExt) '得到的文件扩展名不含有.
if file.filesize<100 then
response.write "<script>alert('请先选择你要上传的文件!');history.back();</script>"
response.end
end if

if fileExt<>"jpg" and fileExt<>"gif" and fileExt<>"bmp" then
response.Write("<script>alert('不允许上传该类型的文件!');history.back();</script>")
response.End()
end if

randomize
ranNum=int(90000*rnd)+10000
filename=cstr(filepath)&cstr(year(date()))&month(date())&day(date())&hour(now())&minute(now())&second(now())&ranNum&"."&fileExt

if file.FileSize>0 then
file.SaveToFile Server.mappath(FileName)
end if
set file=nothing
next
set upload=nothing

if err then
response.Write("<script>alert('文件上传错误!\n错误描述:"&err.description&"');history.back();</script>")
else
response.write("<script>window.parent.document.getElementById('imgpath').value='"&FileName&"';window.parent.chk_imgpath();</script>")
end if
end if
%>
ChinaXtHuLang 2012-08-21
  • 打赏
  • 举报
回复
resurm_upfile.asp查看这个文件,最后返回的值是什么..该怎么改就怎么改.

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧