Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:
PHP
// 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);
    }
?>
Posted
Updated 16-Feb-13 19:55pm
v2
Comments
Sandeep Mewara 17-Feb-13 1:44am    
And the issue is? What have you tried so far?
iDebD 17-Feb-13 1:49am    
below accepting data? reading txt file and sending it is ok. But now whole PDF or doc needed to be uploaded. Sandeep you know how to upload file?
iDebD 17-Feb-13 1:52am    
Hi Sandeep, reading txt file and sending it is ok. But now whole PDF or doc needed to be uploaded. Sandeep you know how to upload file?
iDebD 17-Feb-13 2:30am    
Hi Sandeep, thanks for editing it. Can you give any clue. From your previous post it seems that you know the ans.
Sandeep Mewara 17-Feb-13 2:41am    
Sorry, I would wait for someone to answer as I am not too sure of PHP.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900