Hi all,
Why do I get this error from the below code?..'The filename Copy of myfile.xls is not readable'
The file is stored in a database table. If I select a file path to the server it works fine. Like so...
// Read Excel File
$data->read('uploads/myfile.xls');
Below you will see it reads the file by $row['name'] Is this the correct way?
include('db_connect.php');
// perform query
$query = "SELECT name, type, size, content ".
"FROM excel";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
while ($row = mysql_fetch_array($result))
{
require_once 'Excel/reader.php';
// ExcelFile($filename, $encoding);
$data = new Spreadsheet_Excel_Reader();
// Set output Encoding.
$data->setOutputEncoding('CP1251');
$data->setDefaultFormat('%.1f');
// Read Excel File
$data->read($row['name']);
error_reporting(E_ALL ^ E_NOTICE);
// Display Results
echo '<table>';
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
{
echo '<tr>';
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
{
echo '<td>';
echo $data->sheets[0]['cells'][$i][$j];
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
} // end while
Here's my database table structure:
tbl_name(id, name, type, size, content)
content(BLO😎 - this is the field storing the data. But if I use $row['content'] it just appears a mess.