@@ -307,20 +307,46 @@ version, use ``getMimeType()`` instead:
307
307
Moving Files
308
308
============
309
309
310
+ with Original Filename
311
+ ----------------------
312
+
310
313
Each file can be moved to its new location with the aptly named ``move() `` method. This takes the directory to move
311
314
the file to as the first parameter:
312
315
313
316
.. literalinclude :: uploaded_files/016.php
314
317
315
- By default, the original filename was used. You can specify a new filename by passing it as the second parameter:
318
+ By default, the original filename was used.
319
+
320
+ with New Filename
321
+ -----------------
322
+
323
+ You can specify a new filename by passing it as the second parameter:
316
324
317
325
.. literalinclude :: uploaded_files/017.php
318
326
327
+ Overwriting Existing File
328
+ -------------------------
329
+
330
+ By default, if the destination file already exists, a new filename will be used.
331
+ For example, if **image_name.jpg ** already exists in the directory, then the
332
+ filename will be **image_name_1.jpg ** automatically.
333
+
334
+ You can overwrite the existing file by passing ``true ``
335
+ as the third parameter:
336
+
337
+ .. literalinclude :: uploaded_files/022.php
338
+
339
+ Check if the File Moved
340
+ -----------------------
341
+
319
342
Once the file has been removed the temporary file is deleted. You can check if a file has been moved already with
320
343
the ``hasMoved() `` method, which returns a boolean:
321
344
322
345
.. literalinclude :: uploaded_files/018.php
323
346
347
+ When Moving Fails
348
+ -----------------
349
+
324
350
Moving an uploaded file can fail, with an HTTPException, under several circumstances:
325
351
326
352
- the file has already been moved
0 commit comments