Skip Navigation

[Resolved] I am trying to upload file to custom path

This support ticket is created 6 years, 12 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 3 voices.

Last updated by oliverD 6 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#591776

I am trying to:
I am trying to setup a custom location and path to upload files. I am using the code here to drive the path hidden link

After implementing this code if I upload a file on a form in the wordpress admin it upload to the correct path as dictacted by the customer upload directory above.
The problem is when I try to upload from within the cred form. When I do it from the cred form it creates the folder correctly but it uploads the files to the default wordpress location. year/month etc.

Please advise what is required to get this to work.
Thanks
Oliver

Link to a page where the issue can be seen:

I expected to see:

Instead, I got:

#591896

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - CRED uses internally wp_handle_upload WordPress API function and is getting the info about where upload files are with other API function wp_upload_dir() so we are following precisely the right way to handle the process.
=> https://codex.wordpress.org/Function_Reference/wp_handle_upload

The function expects the upload_dir value to be the default one, or alternatively, to be notified about the new upload directory path(s).

To this purpose one should use upload_dir filter:
=> https://codex.wordpress.org/Plugin_API/Filter_Reference/upload_dir

"This hook allows you to change the directory where files are uploaded to. The keys and values in the array are used by the wp_upload_dir function in WordPress core, which is doing the work."

More info:
=> https://wordpress.stackexchange.com/questions/180353/change-upload-dir-folder-at-a-certain-cpt-but-cant-change-back
=> https://wordpress.stackexchange.com/questions/193089/change-upload-directory-on-custom-plugin-page

#591913

question is when to took exactely for ajax-upload and normal upload.
cred_before save_data for setting filter "upload_dir" and unfilter in "cred_save_data"?

#593620

I had to modify my script to look at the url and see that content type from there.