wp_upload_bits() allows you to put arbitrary binary data into a file, but it selects the path where the file is placed and doesn't allow configuration of this destination besides the basename.

There's always the option of playing with the Filesystem API directly, but I was wondering if there is a similar function to wp_upload_bits() that would wrap the logic for me. Last thing I want is to reinvent the wheel.

It's probably not relevant, but the bits being uploaded are being extracted from image/video metadata. A lot of the functionality is being reworked based on code from wp_generate_attachment_metadata().

  • Why the default location is not good for you? where would you want to locate the generated file? – Mark Kaplun Dec 29 '13 at 9:12
  • Because the file generated needs to be in the same directory as the AV file being parsed in order to work with some other core WP functions. – Dan Dec 29 '13 at 16:56
  • There is the $time parameter that looks like a directory specification, and in any case anything under uploads should be writeable in any way you want so you don't have to use that specific API – Mark Kaplun Dec 29 '13 at 18:10
  • Ah. Good eye. Hadn't realized that time was used to specify a directory under uploads. And yes, I know I don't have to use the Filesystem API, but as much as possible I prefer to let existing WP code handle the work unless existing functionality can't handle what I need. – Dan Dec 30 '13 at 17:33

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.