I used FileEntity httppost to post a file to a php apache server,but I do not want to change the name of the file.
How can I get the name of the file from the server using php? I have already get the file: $filename='test.zip';//自定义的名字 file_get_contents('php://input'); file_put_contents($filename,$data);
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'] );
Just use $_FILES
.
Array
(
[name] => test.jpg
[type] => image/jpeg
[tmp_name] => /tmp/pasd41l3FmFr
[error] => 0
[size] => 15476
)
glob — Find pathnames matching a pattern
foreach (glob("*.*") as $filename) {
print $filename. "
";
}