dimanche 29 mars 2015

wp renaming file before uploading using media_handle_upload

I am creating a plugin which if there is a upload files on specific post it will rename the file then uploads it into wp uploads directory.


I am using media_handle_upload wp function for uploading and this is the code for now.



function setCUstomUploadFile(){
......
require_once( ABSPATH . 'wp-admin/includes/image.php' );
require_once( ABSPATH . 'wp-admin/includes/file.php' );
require_once( ABSPATH . 'wp-admin/includes/media.php' );

// a code for renaming the filename before it uploads
// code here

$attachment_id = media_handle_upload( 'my_image_upload', $_POST['post_id'] );
......


I am not familiar with wordpress internal function so can anyone have an idea about this?


Aucun commentaire:

Enregistrer un commentaire