情况是这样的,我在本地指定的文件夹里有一个图片,我想写一个文件,每当运行这个文件时就自动的把本地的这个图片上传到服务器上,我写了两天没有实现,望哪位朋友帮帮忙!先谢了!

解决方案 »

  1.   

    php怎么能扫描你本地文件夹目录,并选择了上传呢?
    换种方式吧。或者把需求描述清楚些
      

  2.   

    用fwrite函数,手册上的例子:
    <?php
    $filename = 'test.txt';
    $somecontent = "Add this to the file\n";// Let's make sure the file exists and is writable first.
    if (is_writable($filename)) {    // In our example we're opening $filename in append mode.
        // The file pointer is at the bottom of the file hence
        // that's where $somecontent will go when we fwrite() it.
        if (!$handle = fopen($filename, 'a')) {
             echo "Cannot open file ($filename)";
             exit;
        }    // Write $somecontent to our opened file.
        if (fwrite($handle, $somecontent) === FALSE) {
            echo "Cannot write to file ($filename)";
            exit;
        }    echo "Success, wrote ($somecontent) to file ($filename)";    fclose($handle);} else {
        echo "The file $filename is not writable";
    }
    ?>
      

  3.   

    你现在是客户端,你用php向服务端发东西,而php本身就是服务端脚本,这个除非服务端的目录允许你操作
      

  4.   

    楼主的方法是否是通过域名地址的方式传啊(HTTP的包装不支持可写的连接)
      

  5.   

    你写的这个文件放在什么地方运行??
    本地还是服务器。
    放在服务器的话,似乎就不行了。本地运行的话,可以用ftp的方式,发送到服务器。
    或者在服务器 做个上传接口。
    你在本地调用,把图片数据发送过去,服务器端保存。
      

  6.   

    可以的,在本地cmd下调用 php.exe 加文件名.php
      

  7.   

    当然可以!
    先决条件是你在本地执行php程序
      

  8.   

    php ftp socket 技术都可以用啊...用ftp比较好,可能不太安全也可以在服务器上写个php文件接收post数据,保存为文件
    本地模拟客户端把文件读出来,发送过去.这两个文件要比对密钥,只有你自己知道.