0

Hello i'm developing a plugin and the wp_redirect was working well but now it's stop and send me an error that the header have already been sent. Little Schemas

Home page form Post file to add_content.php -> content php treat information and redirect to home page

But now i generate an error into the add_content.php and does not redirect to home anymore.

<?php

use Treck\Dao\ContentVersionManager;
use Treck\Utility\FileReader;

// Testons si le fichier a bien été envoyé et s'il n'y a pas d'erreur
if (isset($_FILES['file_to_upload']) AND $_FILES['file_to_upload']['error'] == 0 ) {


    $contentVersionManger = ContentVersionManager::getInstance();
    $fileContents = FileReader::read_csv_file($_FILES['file_to_upload']);


        if ( !is_null($fileContents))
        {

           $contentVersionManger->addContentsFromFile($fileContents);

           wp_redirect( menu_page_url("labs_list_content" ) );
           exit();
        }

}

New contributor
Babacar is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
7
  • This usually means you've run your redirect too late. Where and how are you running the redirect? – Howdy_McGee Apr 8 at 14:13
  • I just after the content has been Added to the database – Babacar Apr 8 at 14:15
  • if (isset($_FILES['file_to_upload']) and $_FILES['file_to_upload']['error'] == 0) { $contentVersionManger = ContentVersionManager::getInstance(); $contentManger = ContentManager::getInstance(); $fileContents = FileReader::read_csv_file($_FILES['file_to_upload']); if (!is_null($fileContents)) { $contentVersionManger->addContentsFromFile($fileContents); wp_redirect( menu_page_url("labs_list_content" ) ); // exit; } – Babacar Apr 8 at 14:16
  • 1
    @Babacar Please add your code to the question, and explain when exactly it is called. – fuxia Apr 8 at 14:29
  • Do you have any whitespace outside of your PHP tags? – vancoder Apr 8 at 15:41

Your Answer

Babacar is a new contributor. Be nice, and check out our Code of Conduct.

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.