【file_get_contents(string $filename)】【file_put_contents( $sInputFileJpgFull, $bData)】

file_get_contents( $sOutputFile) read the contents of a file into a string, It will use memory mapping techniques if supported by your OS to enhance performance.

file_get_contents(“php://input”) 就是客户端发送过来的POST字符串

php://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives.

php://input is not available with enctype=”multipart/form-data”. A stream opened with php://input can only be read once; the stream does not support seek operations.

同理,php://output is a write-only stream that allows you to write to the output buffer mechanism in the same way as print and echo.

Example #1 Get and output the source of the webpage of a website

$homepage = file_get_contents('http://www.example.com/');
echo $homepage;

Example #2 Searching within the include_path
$file = file_get_contents('./people.txt', FILE_USE_INCLUDE_PATH);
Example #3 Reading a section of a file
// Read 14 characters starting from the 21st character
$section = file_get_contents('./people.txt', NULL, NULL, 20, 14);
var_dump($section);

Example #4 Using stream contexts
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);

/* Save the uploaded jpg image to file */
file_put_contents( $sInputFileJpgFull, $bData);

/*Deletes filename. */
bool unlink ( string $filename [, resource $context ] )

Similar to the Unix C unlink() function. A WARNING level error will be generated on failure.

/*Reads a file and writes it to the output buffer.*/

int readfile ( string $filename [, bool $use_include_path = false [, resource $context ]] )

Fetch images and metadata from PHP server to android

One way to get an image in textform would be to use base64.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: