pre_move_uploaded_file

过滤钩子
apply_filters( 'pre_move_uploaded_file', null, $file, $new_file, $type )
参数
  • (mixed) $move_new_file If null (default) move the file after the upload.
    Required:
  • (array) $file { Reference to a single element from `$_FILES`. @type string $name The original name of the file on the client machine. @type string $type The mime type of the file, if the browser provided this information. @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server. @type int $size The size, in bytes, of the uploaded file. @type int $error The error code associated with this file upload. }
    Required:
  • (string) $new_file Filename of the newly-uploaded file.
    Required:
  • (string) $type Mime type of the newly-uploaded file.
    Required:
定义位置
相关勾子
recovery_mode_emailpre-upload-uiremove_user_from_blogwpmu_upgrade_sitewp_verify_nonce_failed
相关方法
media_upload_fileremove_all_filterswp_max_upload_sizeremove_filterwp_get_upload_dirapache_mod_loaded
引入
4.9.0
弃用
-

pre_move_uploaded_file – 这个钩子在上传的文件被移动到其最终目的地之前被调用。开发人员可以使用这个钩子来修改文件路径或以自定义方式处理文件上传。

过滤是否在通过所有检查后短路移动上传的文件。

如果从过滤器返回非空值,则将完全跳过移动文件和任何相关错误报告。

$move_new_file = apply_filters( 'pre_move_uploaded_file', null, $file, $new_file, $type );

常见问题

FAQs
查看更多 >