1

Is it possibile to read uploaded file by protocol php://fd/?

For example:

<?php
    echo file_get_contents('php://fd/1'); // I quess file descriptor (1) is the name of file input ?>

<form method="post" enctype="multipart/form-data">
    <input type="file" name="1"/>
    <input type="submit" value="ok"/>
</form>
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
l00k
  • 1,525
  • 1
  • 19
  • 29
  • I can use "php://input" I asked becouse I need to get clear text "something" which is in file. I can use char '\0' to manipulate result but php://fd/ would me simplest way.. – l00k May 22 '12 at 11:56
  • 1
    I think what you're looking for is [$_FILES](http://php.net/manual/en/reserved.variables.files.php) - [Also this](http://www.php.net/manual/en/features.file-upload.post-method.php) – Ben May 22 '12 at 11:57
  • 1
    :) I know how to upload file. I am just wonder about this case – l00k May 22 '12 at 12:09
  • Well, I guess you *could* eat soup with a knife, but why bother when you're given a spoon... :) – Ben May 23 '12 at 01:27
  • check [this](https://stackoverflow.com/questions/5256599/what-are-file-descriptors-explained-in-simple-terms) – Accountant م Feb 04 '19 at 17:49

2 Answers2

1

php://fd expects file descriptor. I think you have to create one with fopen on uploaded file and then use it's id.

Eugene
  • 3,280
  • 21
  • 17
0

Try

<?php echo file_get_contents($_FILES["1"]["tmp_name"]); ?>
dpk2442
  • 701
  • 3
  • 8
  • Yes, I know.. But could you tell me is it possible to use php://fd? Is name of input is file descriptor? – l00k May 22 '12 at 12:28