fopen不支持:\B\DATA\File.dat 这种microsoft自己的连接地址方式

解决方案 »

  1.   

    请问 unixdotnet   具体实现的方法,谢谢!
      

  2.   

    如果不用“fopen”,用什么可以读“\B\DATA\File.dat 这种microsoft自己的连接地址方式”?
      

  3.   

    如果目标机器没有提供http或者ftp服务,那应该不行了。
      

  4.   

    我将目标机器的(B机)共享文件夹映射成网络驱动器,还是不能打开文件。为什么asp可以呐?
      

  5.   

    fopen -- 打开文件或者 URL
    $handle = fopen ("/home/rasmus/file.txt", "r");
    $handle = fopen ("/home/rasmus/file.gif", "wb");
    $handle = fopen ("http://www.example.com/", "r");
    $handle = fopen ("ftp://user:[email protected]/somefile.txt", "w");
    如果要访问网络上其它电脑的文件,应该要开通http或ftp服务才行。
      

  6.   

    将目标机器的(B机)共享文件夹映射成网络驱动器,还是不能打开文件。为什么asp可以?
      

  7.   

    if(!($myFile = fopen("\\B\DATA\File.dat", "r")))if(!($myFile = fopen("\\\\B\\DATA\\File.dat", "r")))
      

  8.   

    我错了,我再重新看了php manual,原来这样是可以打开的:<?php $target = '\\\ken\kindergarten\speed.log';
    $content = file_get_contents( $target );

    $handle = fopen( 'other.log', 'wb' );
    fwrite( $handle, $content );
    fclose( $handle );?>
      

  9.   

    能否解释一下,或把下面的代码改成能用的?
    我非常菜,看不懂啊。<?
     print("<H3>通过http协议打开文件</H3>\n");
     // 通过 http 协议打开文件
     if(!($myFile = fopen("\\B\DATA\File.dat", "r")))
     {
      print("文件不能打开");
      exit;
     }
     while(!feof($myFile))    //循环
     {
           // 按行读取文件中的内容
      $myLine = fgetss($myFile, 255);
      print("$myLine <BR>\n");
     }
     // 关闭文件的句柄
     fclose($myFile);
    ?>
      

  10.   

    <?php
             //需要打开的目标文件完整路径
    $target = '\\\机器名\目录\文件名';         //调用file_get_contents获取文件内容
    $content = file_get_contents( $target );

             //建立一个新文件
    $handle = fopen( 'other.log', 'wb' );         //把之前获取目标文件的内容入到新建的文件中
    fwrite( $handle, $content );         //关闭新文件释放资源
    fclose( $handle );?>
      

  11.   

    谢谢unixdotnet() !
    不过,我用的是“PHP Version 4.0.6”没有file_get_contents
    能用别的方法解决么?
      

  12.   

    天啊:file_get_contents 的作用等于 fopen() 加 fread()