10000 [Form][HttpFoundation] Fixes to FileField by Seldaek · Pull Request #83 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form][HttpFoundation] Fixes to FileField #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
4 commits merged into from
Mar 9, 2011
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[HttpFoundation] UploadedFile::getOriginalName is now overriding getName
  • Loading branch information
Seldaek committed Mar 9, 2011
commit 991b1ed22504de51fe2ebca6eb898c4fa4da2e0c
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/FileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function preprocessData(array $data)
default:
$data['file']->move($this->getTmpDir());
$data['file']->rename($this->getTmpName($data['token']));
$data['original_name'] = $data['file']->getOriginalName();
$data['original_name'] = $data['file']->getName();
$data['file'] = '';
break;
}
Expand Down
15 changes: 10 additions & 5 deletions src/Symfony/Component/HttpFoundation/File/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/*
* This file is part of the Symfony package.
*
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
Expand Down Expand Up @@ -101,13 +101,18 @@ public function getMimeType()
}

/**
* Returns the original file name including its extension.
* Returns the absolute file name without dots
*
* Until the uploaded file is moved, it will return the name of the temporary file
*
* @returns string The file name
* @returns string The file path
*/
public function getOriginalName()
public function getName()
{
return $this->originalName;
if (!$this->moved) {
return $this->originalName;
}
return parent::getName();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Symfony/Tests/Component/Form/FileFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testSubmitUploadsNewFiles()
$that->createTmpFile($tmpPath);
}));
$file->expects($this->any())
->method('getOriginalName')
->method('getName')
->will($this->returnValue('original_name.jpg'));

$this->field->submit(array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function testGetOriginalName()
null
);

$this->assertEquals('original.gif', $file->getOriginalName());
$this->assertEquals('original.gif', $file->getName());
}
}
}
0