Skip to content

Commit

Permalink
check if file isValid()
Browse files Browse the repository at this point in the history
the `isValid()` method checks whether the file was uploaded successfully, and also calls `is_uploaded_file()`, which validates the file has been uploaded, and helps prevent mailcious users from reading other files on the system.

there is no need to check for the file existence because the constructor on `Symfony\Component\HttpFoundation\File\File` checks if the passed path is a file using `is_file()`.

also updated test
  • Loading branch information
browner12 committed Jul 24, 2018
1 parent bc4f8ea commit f8d5407
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function storeAs($path, $name, $options = [])
*/
public function getContents()
{
if (file_exists($this->getPathname())) {
if ($this->isValid()) {
return file_get_contents($this->getPathname());
}

Expand Down

0 comments on commit f8d5407

Please sign in to comment.