Read xls

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
greg7
Forum Commoner
Posts: 32
Joined: Tue Oct 13, 2009 7:38 am

Read xls

Post by greg7 »

Hi guys i am a CS student, i made a web application but i need a little help. I use a class to parse xls which is provided here http://code.google.com/p/php-excel-reader/. Sometimes when I upload a .xls I get that the filename is not readable, when I run the application on localhost I have no problems. So I' ve checked for permissions and for the path but they are ok, its driving me insane because a get the error once and then if I refresh the page and try again, it works properly, some other times it will not work even if I refresh the page dozen of times. I use the following

Code: Select all

$tempFile = $_FILES['ufile']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . '/dea/uploads/';
//$targetPath = 'uploads/';
//echo "$targetPath<br/>";

$targetFile =  str_replace('//','/',$targetPath) . $_FILES['ufile']['name'];
//echo "$targetFile<br/>";		
					
move_uploaded_file($tempFile,$targetFile);	
		 			
chmod($targetFile, 0755);
		  		
//Create new instance 
$excel = new Spreadsheet_Excel_Reader();
//$excel->setOutputEncoding('CP1251');
$excel->read($targetFile);
If anyone had the same problem or can assist me it would be greatly appreciated, thanks in advance!
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Read xls

Post by AbraCadaver »

You're not going to be able to have a / in the filename because it will be seen as a path when you try to move it or open it.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
greg7
Forum Commoner
Posts: 32
Joined: Tue Oct 13, 2009 7:38 am

Re: Read xls

Post by greg7 »

Thanks for your interest but i think in this case it wouldn't work at anyntime. But sometimes works when others not.
Post Reply