0

我使用 FileEntity httppost 将文件发布到 php apache 服务器,但我不想更改文件名。

如何使用 php 从服务器获取文件名?我已经拿到文件了: $filename='test.zip';//自定义的名字 file_get_contents('php://input'); file_put_contents($filename,$data);

4

2 回答 2

1

HTML (test.html):

<!-- Make sure you have enctype and a name on your file input -->
<form method="post" action="test.php" enctype="multipart/form-data">
    <input type="file" name="test" />
    <button>Submit</button>
</form>

PHP (test.php):

// Since we've set our file input to name 'test' and 
// we've posted form-data, we can use $_FILES

print_r( $_FILES['test'] );

只需使用$_FILES.

Array
(
    [name] => test.jpg
    [type] => image/jpeg
    [tmp_name] => /tmp/pasd41l3FmFr
    [error] => 0
    [size] => 15476
)
于 2012-07-02T14:59:09.710 回答
0

glob — 查找匹配模式的路径名

foreach (glob("*.*") as $filename) {
    print $filename. "\n";
}
于 2012-07-02T15:04:02.023 回答