我正在编辑一个当前的网站。我想将文件上传机制从http改为ftp。他们使用文件模块和Drupal 7.我需要的是,在一种形式中,当我选择要上传的文件时,我如何获得他们的机器路径(例如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!"));
}
}
}
现在这就是他们处理文件提交的方式