reading absolute path file

Topics: Developer Forum
Jun 17, 2011 at 12:30 PM

Hi all,

I have a problem reading csv file with full absolute path. Can anyone help me to read a file with absolute path. Please check the code below:

Thank you in advance

example:

require_once 'PHPExcel.php';
date_default_timezone_set('Europe/London');
$csvFileName="[FULL_SITE_PATH]/mycsv.csv"; // http://rajanmaharjan.com.np/mycsv.csv
$objReader = PHPExcel_IOFactory::createReader('CSV');
$objReader->setInputEncoding('UTF-8');
$objPHPExcel = $objReader->load($csvFileName);

 

Is there any way to read a file with absolute path.

Jun 17, 2011 at 2:43 PM

I think you first have to fetch the file, as it is located on a website. You are confusing an absolute path (wich should be local) with a URL pointing to a page somewhere on the internet!

if you have fopen wrappers enabled you can download the file using

file_put_contents(file_get_contents('https://blabla'), '/tmp/test');



and then open the downloaded file... ;)

Jun 18, 2011 at 6:03 PM

Thank borft for the reply and i am sorry that I couldnt clear you the post earlier.

I wanted to read a CSV file from other server.

I have my website called http://mywebsite.com/read.php

from this site I wanted to read a file called http://rajanmaharjan.com.np/mycsv.csv. Is this possible using  PHPExcell?