mình tạo component cho phép đọc file excel(có file
reader.php hỗ trợ đọc file excel) - browse chọn file, nhấn upload. Đã upload file lên thành công, nhưng đọc file thì không đọc được? Nhờ các bạn xem giúp giùm.
Các file như sau:
file admin.x_diem.html.php
file admin.x_diem.php
……
switch($task){
case 'upload':
uploadFile();
break;
}
function uploadFile()
{
$target_path = "C://wamp/www/administrator/components/com_upload/uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
echo "File has been uploaded";
$fileType = $_FILES['uploadedfile']['type'];
$fileName = $_FILES['uploadedfile']['name'];
if ($fileType != 'application/vnd.ms-excel'
{
echo 'Please choose file Excel';
exit;
}
else
{ //don't read file Excel: Error
include_once('reader.php'
;//include the reader class file
$xl_reader = new Spreadsheet_Excel_Reader();//Make an instance of the class
$xl_reader->read($fileName);
$rows = $xl_reader->sheets[0]['numRows'];
$cols = $xl_reader->sheets[0]['numCols'];
echo "Dong: ".$rows.""."Cot: ".$cols."";
}
}
else
echo "Error uploading the file";
}
Error:
File has been uploaded
The filename diemthi.xls is not readable
Component + file excel thử đính kèm
File gửi kèm:
Vui lòng đăng nhập để tải file
Độ lớn file: 16949