Dumb_Shock
Dumb_Shock

Reputation: 1008

PHP -- Directory installation

I want to play with excel sheet in PHP. So i found out PHPExcel provides that option. But i am having a problem in setting up of the PHPExcel in my directory.

It says:

Extract and copy Classes to your includes/libraries directory. On your script, the minimum code you need to do is:

require_once dirname(__FILE__) . '/PHPExcel/PHPExcel.php'; 

I am not running PHP locally on my computer, So i do not have access to PHP remote directories.

What should i do?

Upvotes: 2

Views: 379

Answers (2)

Nodashi
Nodashi

Reputation: 19

Supposing you are in the root directory / of your host.

You have to upload PHPExcel's classes in a directory, usualy /PHPExcel/

Then, if your script is at the root of your host, you just have to add require_once dirname(__FILE__) . '/PHPExcel/PHPExcel.php'; just after your php opening tag.

Upvotes: 1

David Barker
David Barker

Reputation: 14620

This assumes you have a folder to upload to on a webserver that is running PHP:

I think you're a little confused by the way you have worded your question.

Your includes / libraries directory is one of your choosing, you can place the scripts anywhere and then use require() / require_once() to include the classes in the script you would like to use their objects in.

To break down the example:

require_once dirname(__FILE__) . '/PHPExcel/PHPExcel.php'; 

dirname(__FILE__) - FILE is a constant for use with any script. i.e. it is declared by the base PHP files not any scripts you create. It returns the absolute path to the current PHP script running (in relation to the document root). using dirname() evaluates FILE and returns the path without the script file location.

i.e.

dirname(__FILE__) = c:/docs/www/root/index.php

would be evaluated as:

c:/docs/www/root

So to wrap this up, place the documents in a directory above your web root folder. And require them from there.

Hope that helps.

Upvotes: 2

Related Questions