0
我正在使用Drupal 6和filefield module。Drupal 6:如何實現一個鉤子?
我創建了一個簡單的表單將圖像上傳到服務器。我想在上傳之前重命名文件。我注意到,在field_file_save_upload
函數中,提到了實現hook_file_insert
允許您操作文件的屬性。我不知道如何實現這個鉤子。我應該在新模塊中實現它,還是直接在field_file.inc文件中實現它?它應該被命名爲field_file_insert
?
的文檔指出以下幾點:
/**
* Save a file upload to a new location.
* The source file is validated as a proper upload and handled as such. By
* implementing hook_file($op = 'insert'), modules are able to act on the file
* upload and to add their own properties to the file.
...
*/
function field_file_save_upload($source, $validators = array(), $dest = FALSE)
謝謝!關於不修改核心代碼是完全正確的,我會嘗試找到更通用的解決方案,以便使用此特定模塊重命名上傳的文件。 – jdecuyper 2011-02-15 19:18:40