0

私はしばらく探していましたが、私のように php-noob では動作しません。

私が達成しようとしているのは、ルートにディレクトリを作成し、それぞれに画像とtxtファイルを作成する方法です。それで、あなたが得たとしましょう:

 Root
 |
 +---Directory 1
 |   |
 |   +---Image1.jpg
 |   |
 |   +---Image2.jpg
 |   |
 |   +---Text.txt
 |
 +---Directory 2
     |
     +---Image1.jpg
     |
     +---Image2.jpg
     |
     +---Text.txt

画像と名前を読んで表示する方法を知っています。しかし、付随するテキストファイルを表示するにはどうすればよいですか? (ファイルのタイトルではなく、内容です)。

とても有難い!

4

2 に答える 2

1

最も簡単な方法は、file_get_contents ( http://php.net/manual/en/function.file-get-contents.php )を使用することです。

echo file_get_contents($path_to_file);

より高度な: fopen/fread http://php.net/manual/en/function.fread.php

于 2010-09-14T00:34:53.720 に答える
0

PHP fpassthru マニュアルから:

<?php

// open the file in a binary mode
$name = './img/ok.png';
$fp = fopen($name, 'rb');

// send the right headers
header("Content-Type: image/png");
header("Content-Length: " . filesize($name));

// dump the picture and stop the script
fpassthru($fp);
exit;

?>
于 2010-09-14T00:36:20.210 に答える