Page 1 of 1

Read xls

Posted: Mon May 10, 2010 10:27 am
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!

Re: Read xls

Posted: Mon May 10, 2010 11:23 am
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.

Re: Read xls

Posted: Mon May 10, 2010 12:43 pm
by greg7
Thanks for your interest but i think in this case it wouldn't work at anyntime. But sometimes works when others not.