[wp-trac] [WordPress Trac] #49658: Incorrect Upload Directory path using wp_upload_dir()

WordPress Trac noreply at wordpress.org
Mon Mar 23 13:25:44 UTC 2020


#49658: Incorrect Upload Directory path using wp_upload_dir()
-------------------------------+------------------------------
 Reporter:  amitkumarsingh     |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Upload             |     Version:  5.3.2
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by amitkumarsingh):

 Hi sorry for the delay on this.
 Below is the code I am using:
 {{{
 add_action( 'init', 'file_creation_test' );
 function file_creation_test() {
         require_once plugin_dir_path(__DIR__) . '/vendor/autoload.php';
         $upload_dir     = wp_upload_dir();
         $wqr_upload_dir = $upload_dir['basedir'] . '/testing';

         $php_word = new \PhpOffice\PhpWord\PhpWord();
         $section = $php_word->addSection();
         $section->addText( 'Word Test file' );

         $obj_writer = \PhpOffice\PhpWord\IOFactory::createWriter(
 $php_word, 'Word2007' );
         $obj_writer->save( $wqr_upload_dir . '/test_word.docx' );
 }
 }}}

 I am using PhpOffice/PhpWord to create a document. I have attached its
 library above.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49658#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list