I have a custom plugin to add project documents in my Wordpress site. Now these documents should be stored in their respective project folder such as:


Documents meta data is stored in a custom table and is given through an API, which is not the question.

Let say I am given following document and meta data via an API POST.

        "file": {
         "file": {

After I get this data, I want to upload this document under wp-content/uploads/EN001 directory. Since I wouldn't know the directory name in advance I can't use wp_upload filter to change uploaddirectory.

Is there any way I can change upload directory according to the project I get via the api like above so that


Update #1:

The proposed solution doesn't fix my problem because I can't pass the paths per file to the upload_dir filter. My problem is each file will be uploaded in the different folder and I want to be able to pass the folder structure for each file where it will be stored.

  • @denis.stoyanov it isn't the duplicate and kindly check my update #1 section – Ghazanfar Mir Aug 5 '15 at 11:18
  • can't you store the files as an array prior to the update with proper html5 markup of the form? Edit 1: Removed the "duplicate" comment – denis.stoyanov Aug 5 '15 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.