如何在形式drupal 7中添加图像字段

如何在形式drupal 7中添加图像字段

问题描述:

i am creating a form as shown in image which saves detail in csv in background by putting php code in body block which works fine but can anyone tell me how to add the image upload option in form and to save the same in other place

enter image description here

我正在创建一个如图所示的表单,它通过将php代码放在body块中来保存csv中的详细信息。 工作正常,但任何人都可以告诉我如何在表单中添加图像上传选项,并将其保存在其他地方 p>

p> div>

First do not add code in body block. Create a custom module.

To add image field please refer Drupal Form API.

Eg.

$form['image_example_image_fid'] = array(
  '#title' => t('Image'),
  '#type' => 'managed_file',
  '#description' => t('The uploaded image will be displayed on this page using the image style choosen below.'),
  '#default_value' => variable_get('image_example_image_fid', ''),
  '#upload_location' => 'public://image_example_images/',
);