Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d7ecc7

Browse files
committed
Merge pull request symfony#512 from gimler/master
Fix php warning when no file was uploaded
2 parents 8715713 + 1e24827 commit 3d7ecc7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cookbook/doctrine/file_uploads.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ object, which is what's returned after a ``file`` field is submitted::
189189
public function upload()
190190
{
191191
// the file property can be empty if the field is not required
192-
if (!$this->file) {
192+
if (empty($this->file)) {
193193
return;
194194
}
195195

@@ -246,7 +246,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
246246
*/
247247
public function preUpload()
248248
{
249-
if ($this->file) {
249+
if (!empty($this->file)) {
250250
// do whatever you want to generate a unique name
251251
$this->setPath(uniq().'.'.$this->file->guessExtension());
252252
}
@@ -257,7 +257,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
257257
*/
258258
public function upload()
259259
{
260-
if (!$this->file) {
260+
if (empty($this->file)) {
261261
return;
262262
}
263263

@@ -304,7 +304,7 @@ property, instead of the actual filename::
304304
*/
305305
public function preUpload()
306306
{
307-
if ($this->file) {
307+
if (!empty($this->file)) {
308308
$this->setPath($this->file->guessExtension());
309309
}
310310
}
@@ -314,7 +314,7 @@ property, instead of the actual filename::
314314
*/
315315
public function upload()
316316
{
317-
if (!$this->file) {
317+
if (empty($this->file)) {
318318
return;
319319
}
320320

0 commit comments

Comments
 (0)