core/src/Pluf/Form/FieldFile.php

Classes

Pluf_Form_Field_File Default form field.

Functions

Pluf_Form_Field_File_moveToUploadFolder()

Pluf_Form_Field_File_moveToUploadFolder(  $value,   $params = array()) : string

Default move function. The file name is sanitized.

In the extra parameters, options can be used so that this function is matching most of the needs:

  • 'upload_path': The path in which the uploaded file will be stored.

  • 'upload_path_create': If set to true, try to create the upload path if not existing.

  • 'upload_overwrite': Set it to true if you want to allow overwritting.

  • 'file_name': Force the file name to this name and do not use the original file name. If this name contains '%s' for example 'myid-%s', '%s' will be replaced by the original filename. This can be used when for example, you want to prefix with the id of an article all the files attached to this article.

If you combine those options, you can dynamically generate the path name in your form (for example date base) and let this upload function create it on demand.

Parameters

$value
$params

Returns

string —

Name relative to the upload path.