File_get_contents error

I am so close to getting what I want. I have converted a number of pdf files to text. I then renamed the files with php extension so that I can include the contents above the form that selects the files. It all works except php is reporting it cannot find the file. If I manually copy the missing file name and post it in the browser, the file comes up. Here is the error

4580_govincompetence.php

Warning : file_get_contents( 4580_govincompetence.php ): Failed to open stream: No such file or directory in /home/funkandg/!sites/mike/combolisk.org/www/mikedocs/anna/offline/0108anna.php on line 14

End of 4580_govincompetence.php

Here is the code;

<?php
//retrieve playlist from checkboxes this is code to display index of anna blog posts
echo "anna.php version 1.08 <br>";
if (isset($_POST['submit'])){
    	
	echo "submit set";

        echo "looking for checked contents";
        if(!empty($_POST['check'])) {
		foreach($_POST['check'] as $fname) {

			echo "<br>" . $fname . "<br>";

			echo file_get_contents($fname) . "<br> End of $fname <br>";
			
    
        		
          	}
	}

  }

// **************** build filename and checkbox content
      echo "Thank you. Use the button above the text to listen";

 	echo "<style> th, td { border: 1px solid black; } </style>";

    	echo "<h1>Select all the articles you would like to review or listen to</h1>";
    	echo "<p>Please select the checkboxes for articles you want displayed. Continue to the text and use the audio button to listen.</p>";

   	echo '<form action = # method = "post">';
      	echo '<button type = "submit" name = "submit">Load</button>';
      	echo '<table style="width:100%">';
      	echo "<tr>";
            echo "<th>Check</th>";
            echo "<th>#</th>";
            echo "<th>Date</th>";
            echo "<th>Title</th>";
      	echo "</tr>";

$findex="index_csv.csv";
if (($handle=fopen ($findex, "r")) !==FALSE){
	while(($line =  fgetcsv($handle)) !== FALSE) {
 		list($totstring, $totlen, $period, $http, $lenanna, $lentitle, $post, $title, $fnamelen, $old,$fnameless, $bat, $pdate) = $line;
		$new=$post . "_". $fnameless . ".php"; // this adds the post number to the beginning of the file name. see renamewithpost.php
		
		

 
 	echo "<tr>";
            echo "<td><input type = \"checkbox\" name = \"check[]\" value = \" $new \"> $new </td>";
            echo "<td>$post</td>";
            echo "<td>$pdate</td>";
	    echo "<td>$title</td>";
            
      	echo "</tr>";
	}
   }
fclose($handle);


//*****************************************************

	echo "</table>";
//end loop for checkbox rows

// hidden box for security
    	echo '<input type = "text" name="hidden" placeholder = "not used">';
	echo "</form>";

?>

You are putting space characters before/after the $new value in the value attribute.

I also recommend that instead of using escaped double-quotes, that you just use single-quotes.

I tried a few things including adding the path to the root and found the blank space as well. Thank you. Now I just need to figure out how to drop it in a WordPress page so I can use my text to speech plug in.

Sponsor our Newsletter | Privacy Policy | Terms of Service