使用PHP进行基于HTTP的上传 [英] HTTP based uploading using PHP

查看:63
本文介绍了使用PHP进行基于HTTP的上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将PDF文件上传到运行php脚本的服务器。我是PHP新手,不知道如何编写这个脚本。我不能使用FTP上传。我必须使用基于HTTP的上传。

更多说明:

上传将由C ++完成(我可以做到)

接收将是用PHP脚本完成(需要帮助)

任何人都可以帮忙吗?



谢谢



来自OP的更新:

Hi, I want to upload a PDF file to server where a php script is running. I am new to PHP have no idea how to write this script. I cann''t use FTP uploading. I have to use HTTP based uploading.
More clarification:
Upload will be done by C++ (I can do that)
Receive will be done in PHP script(Need help here)
Can any one help?

Thanks

UPDATE from OP:

// body contains sent data here
    $body = file_get_contents('php://input');

    //If will execute for install time....
    $StrOneTmp = strstr($body, "HOSTNAME_", FALSE);
    if(FALSE != $StrOneTmp)
    {
        //$StrOneTmp = strstr($body, '_', false);
        $StrOneTmp = strrev($StrOneTmp);
        $StrOneTmp = strstr($StrOneTmp, '_', TRUE);
        $StrOneTmp = strrev($StrOneTmp);
        mkdir($StrOneTmp);
    }

    //This is data
    $StrTmp = strstr($body, "[...]", FALSE);
    if( FALSE != $StrTmp )
    {
        $data = strstr($body, '[', TRUE); //fine

        $HostFolder = $body;
        $HostFolder = strrev($HostFolder);
        $HostFolder = strstr($HostFolder, ']', TRUE);
        $HostFolder = strrev($HostFolder);

        $today = date("dmY-Gis");
        $name = $today . ".log";
        $FilePath = $HostFolder . "\\" . $name;

        $f = fopen($FilePath, "w+");
        if(NULL == $f)
        {
            mkdir($HostFolder);
        }
        $f = fopen($FilePath, "w+");
        fwrite($f, $data);
        fclose($f);
    }
?>

推荐答案

body = file_get_contents(' php:// input');

// 如果执行安装时间....
body = file_get_contents('php://input'); //If will execute for install time....


StrOneTmp = strstr(
StrOneTmp = strstr(


body, HOSTNAME _,FALSE);
if(FALSE!=
body, "HOSTNAME_", FALSE); if(FALSE !=


这篇关于使用PHP进行基于HTTP的上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆