0

我现在正在编辑一个当前的网站。我想将文件上传机制从 http 更改为 ftp。他们在 Drupal 7 中使用 File 模块。我需要的是,在一个表单中,当我选择要上传的文件时,我怎样才能获得他们的机器路径(例如 C:\path/to/file.mov)?我需要在 php ftp_nb_put 函数中使用此路径。

function assets_managed_file_form_upload_submit($form, &$form_state) {


  for ($i = 0; $i < $form_state['num_files']; $i++) {
    if ($form_state['values']['files_fieldset']['managed_field'][$i] != 0) {

      // Make the file permanent.
      $file = file_load($form_state['values']['files_fieldset']['managed_field'][$i]);
      $file->status = FILE_STATUS_PERMANENT;
      $directory = 'private://cubbyhouse/'. $form_state['values']['allowed_user'];
      file_prepare_directory($directory, FILE_CREATE_DIRECTORY);


      $file->uri = file_unmanaged_copy($file->uri, $directory, FILE_EXISTS_REPLACE);
      $file->uid = $form_state['values']['allowed_user'];
      drupal_chmod($file->uri);
      file_save($file);

      //drupal_set_message(t($debug=print_r($form)));

      // Need to add an entry in the file_usage table.
      file_usage_add($file, 'assets', 'image', 1);

      drupal_set_message(t("Your file has been uploaded!"));
    }
  }
}

现在这就是他们处理文件提交的方式

4

0 回答 0