Click here to Skip to main content
12,626,508 members (38,292 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: PHP
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);
    }
?>
Posted 16-Feb-13 19:59pm
iDebD842
Updated 16-Feb-13 20:55pm
v2
Comments
Sandeep Mewara 17-Feb-13 1:44am
   
And the issue is? What have you tried so far?
bubaidada 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?
bubaidada 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?
bubaidada 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.
bubaidada 17-Feb-13 2:57am
   
ok...

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100