免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2124 | 回复: 2
打印 上一主题 下一主题

html文件中的路径转换问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-07-27 23:08 |只看该作者 |倒序浏览
我目前在做一个网站,客户是只有很少计算机知识的教师。
要求能方便更新。
我的解决方案是,所有文档用word编辑,然后另存为html文件。
同过表单的方式上传到网站上,嵌入到已设定好的统一界面中。
现在的问题是,客户要求在文档中嵌入图片。
word文档另存为html文件后如果有图像回在同一路径下建立一个同名目录,html内到图片的连接为相对链接。而图片上传到网站后主控浏览页面和文档页面不在同一路径,在浏览页面中嵌入文档页面是文档找不到对应图像了。
比如:更节点为/
文档页面为/introduce/sss1.htm

  1. <html xmlns:v="urn:schemas-microsoft-com:vml"
  2. xmlns:o="urn:schemas-microsoft-com:office:office"
  3. xmlns:w="urn:schemas-microsoft-com:office:word"
  4. xmlns="http://www.w3.org/TR/REC-html40">;

  5. <head>;
  6. <meta http-equiv=Content-Type content="text/html; charset=GB2312">;
  7. <meta name=ProgId content=Word.Document>;
  8. <meta name=Generator content="Microsoft Word 9">;
  9. <meta name=Originator content="Microsoft Word 9">;
  10. <link rel=File-List href="./sss1.files/filelist.xml">;
  11. <link rel=Edit-Time-Data href="./sss1.files/editdata.mso">;
  12. <!--[if !mso]>;
  13. <style>;
  14. v\:* {behavior:url(#default#VML);}
  15. o\:* {behavior:url(#default#VML);}
  16. w\:* {behavior:url(#default#VML);}
  17. .shape {behavior:url(#default#VML);}
  18. </style>;
  19. <![endif]-->;
  20. <title>; </title>;
  21. <!--[if gte mso 9]>;<xml>;
  22. <o:DocumentProperties>;
  23.   <o:Author>;Hoxide</o:Author>;
  24.   <o:LastAuthor>;Hoxide</o:LastAuthor>;
  25.   <o:Revision>;1</o:Revision>;
  26.   <o:TotalTime>;1</o:TotalTime>;
  27.   <o:Created>;2003-07-27T14:49:00Z</o:Created>;
  28.   <o:LastSaved>;2003-07-27T14:50:00Z</o:LastSaved>;
  29.   <o:Pages>;1</o:Pages>;
  30.   <o:Company>;Hydrogen_Oxide</o:Company>;
  31.   <o:Lines>;1</o:Lines>;
  32.   <o:Paragraphs>;1</o:Paragraphs>;
  33.   <o:Version>;9.2812</o:Version>;
  34. </o:DocumentProperties>;
  35. </xml>;<![endif]-->;<!--[if gte mso 9]>;<xml>;
  36. <w:WordDocument>;
  37.   <w:PunctuationKerning/>;
  38.   <w:DrawingGridVerticalSpacing>;7.8 磅</w:DrawingGridVerticalSpacing>;
  39.   <w:DisplayHorizontalDrawingGridEvery>;0</w:DisplayHorizontalDrawingGridEvery>;
  40.   <w:DisplayVerticalDrawingGridEvery>;2</w:DisplayVerticalDrawingGridEvery>;
  41.   <w:Compatibility>;
  42.    <w:SpaceForUL/>;
  43.    <w:BalanceSingleByteDoubleByteWidth/>;
  44.    <w:DoNotLeaveBackslashAlone/>;
  45.    <w:ULTrailSpace/>;
  46.    <w:DoNotExpandShiftReturn/>;
  47.    <w:AdjustLineHeightInTable/>;
  48.    <w:UseFELayout/>;
  49.   </w:Compatibility>;
  50. </w:WordDocument>;
  51. </xml>;<![endif]-->;
  52. <style>;
  53. <!--
  54. /* Font Definitions */
  55. @font-face
  56.         {font-family:宋体;
  57.         panose-1:2 1 6 0 3 1 1 1 1 1;
  58.         mso-font-alt:SimSun;
  59.         mso-font-charset:134;
  60.         mso-generic-font-family:auto;
  61.         mso-font-pitch:variable;
  62.         mso-font-signature:3 135135232 16 0 262145 0;}
  63. @font-face
  64.         {font-family:"\@宋体";
  65.         panose-1:2 1 6 0 3 1 1 1 1 1;
  66.         mso-font-charset:134;
  67.         mso-generic-font-family:auto;
  68.         mso-font-pitch:variable;
  69.         mso-font-signature:3 135135232 16 0 262145 0;}
  70. /* Style Definitions */
  71. p.MsoNormal, li.MsoNormal, div.MsoNormal
  72.         {mso-style-parent:"";
  73.         margin:0cm;
  74.         margin-bottom:.0001pt;
  75.         text-align:justify;
  76.         text-justify:inter-ideograph;
  77.         mso-pagination:none;
  78.         font-size:10.5pt;
  79.         mso-bidi-font-size:12.0pt;
  80.         font-family:"Times New Roman";
  81.         mso-fareast-font-family:宋体;
  82.         mso-font-kerning:1.0pt;}
  83. /* Page Definitions */
  84. @page
  85.         {mso-page-border-surround-header:no;
  86.         mso-page-border-surround-footer:no;}
  87. @page Section1
  88.         {size:595.3pt 841.9pt;
  89.         margin:72.0pt 90.0pt 72.0pt 90.0pt;
  90.         mso-header-margin:42.55pt;
  91.         mso-footer-margin:49.6pt;
  92.         mso-paper-source:0;
  93.         layout-grid:15.6pt;}
  94. div.Section1
  95.         {page:Section1;}
  96. -->;
  97. </style>;
  98. </head>;

  99. <body lang=ZH-CN style='tab-interval:21.0pt;text-justify-trim:punctuation'>;

  100. <div class=Section1 style='layout-grid:15.6pt'>;

  101. <p class=MsoNormal>;<span lang=EN-US>;<!--[if gte vml 1]>;<v:shapetype id="_x0000_t75"
  102. coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
  103. filled="f" stroked="f">;
  104. <v:stroke joinstyle="miter"/>;
  105. <v:formulas>;
  106.   <v:f eqn="if lineDrawn pixelLineWidth 0"/>;
  107.   <v:f eqn="sum @0 1 0"/>;
  108.   <v:f eqn="sum 0 0 @1"/>;
  109.   <v:f eqn="prod @2 1 2"/>;
  110.   <v:f eqn="prod @3 21600 pixelWidth"/>;
  111.   <v:f eqn="prod @3 21600 pixelHeight"/>;
  112.   <v:f eqn="sum @0 0 1"/>;
  113.   <v:f eqn="prod @6 1 2"/>;
  114.   <v:f eqn="prod @7 21600 pixelWidth"/>;
  115.   <v:f eqn="sum @8 21600 0"/>;
  116.   <v:f eqn="prod @7 21600 pixelHeight"/>;
  117.   <v:f eqn="sum @10 21600 0"/>;
  118. </v:formulas>;
  119. <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>;
  120. <o:lock v:ext="edit" aspectratio="t"/>;
  121. </v:shapetype>;<v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:303.75pt;
  122. height:287.25pt'>;
  123. <v:imagedata src="[color=#FF0000]./sss1.files/image001.jpg[/color]" o:title="1018605474532"/>;
  124. </v:shape>;<![endif]-->;<![if !vml]>;<img width=405 height=383
  125. src="[color=#FF0000]./sss1.files/image001.jpg[/color]" v:shapes="_x0000_i1025">;<![endif]>;</span>;</p>;

  126. </div>;

  127. </body>;

  128. </html>;
复制代码


还有与文档同名的目录/introduce/sss1

浏览页面为 /main/sy.php

  1. <html>;
  2. <head>;
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">;
  4. <title>;无标题文档</title>;
  5. </head>;

  6. <body>;
  7. <?php
  8.                                 $size = filesize("../introduce/sss1.htm");
  9.                                 $pointer = fopen("../introduce/sss1.htm", "r");
  10.                                 while ($line = fgets($pointer,$size))
  11.                                 {
  12.                                         print($line);
  13.                                 }
  14.                                 fclose($pointer);
  15. ?>;
  16. </body>;
  17. </html>;
复制代码

包含后生成的html文件和原文件相同,但路径为/main/所以图片不能定位,各位高手有什么好的建议吗?

论坛徽章:
0
2 [报告]
发表于 2003-07-28 11:51 |只看该作者

html文件中的路径转换问题

没人回吗?好歹也该给点建议吧。

论坛徽章:
0
3 [报告]
发表于 2003-07-28 11:59 |只看该作者

html文件中的路径转换问题

这个问题基本解决:在显示的时候将"./"替换为正确的目录。

  1. $size = filesize("../introduce/sss1.htm");
  2. $pointer = fopen("../introduce/sss1.htm", "r");
  3. while ($line = fgets($pointer,$size))
  4. {
  5.         $trans = array("./" =>; "../introduce/");
  6.         $line=strtr($line,$trans);
  7.         print($line);
  8. }
  9. fclose($pointer);
复制代码


现在有新的问题了,如何同时上传多个文件呢?
最主要的是在给定本地word文档名后,如何搜索到相关的目录,并把目录中的文件也上传的正确位置?
上传文件有两种方式一种是post,一种是put,查看资料觉得用put可能可以解决,但所有服务器都支持put吗,手册中只提到apache、Netscape Composer等?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP