Files

Introduction

Exception provides native files, images and ftp engines based on http/storage/APP-STORAGE-FOLDER/ directory and on FTP connection configuration into env file.

This engine lets you to work with local and remote (FTP) files and images and you can access to them in every controller using $this->file() or $this->image() methods.

You can also use them everywhere within $app->file() or $app->image() but you have to get istance global $app;.

Files helpers



$this->file->exists(FILE)

This function verifies if a FILE exists and returns a TRUE or FALSE value.



$this->file->extension(FILE)

This function returns a FILE extension.



$this->file->read(FILE)

This function reads a FILE and returns a string.



$this->file->create(FILE, CONTENT)

This function creates a FILE with a CONTENT and returns a string.



$this->file->createdir(DIR)

This function creates a DIR.



$this->file->delete(FILE)

This function deletes a FILE.



$this->file->deletedir(DIR)

This function deletes a DIR.



$this->file->list(DIR)

This function lists the files into a DIR and returns an array.



$this->file->upload(DIR, MAXSIZE, EXTENSIONS)

This function uploads all $_FILES into a DIR verifing files EXTENSIONS (array) and file maxsize (in bytes) and returns an array within files upload status and names.



$this->file->forcedownload(FILE)

This function forces FILE download.

Images helpers



$this->image->load(FILE)

This function loads image FILE and init image() function.



$this->image->save(FILE)

This function saves current image into FILE path.



$this->image->output(TYPE)

This function shows current image as extention TYPE.



$this->image->getWidth(FILE)

This function returns FILE width in px.



$this->image->getHeight(FILE)

This function returns FILE height in px.



$this->image->resizeToWidth(PX)

This function resizes current image to width PX.



$this->image->resizeToHeight(PX)

This function resizes current image to height PX.



$this->image->scale(RATIO)

This function scales current image to a RATIO value.



$this->image->resize(W, H)

This function resizes current image to defined W and H pixel.



$this->image->crop(PIXEL)

This function crops current image to a defined PIXEL measure (centered and squared croped).

FTP helpers



$this->file->ftpget(LOCALFILE, REMOTEFILE)

This function lets you to download a remote FTP file into a local file.



$this->file->ftpput(LOCALFILE, REMOTEFILE)

This function lets you to upload a local file into a remote FTP file.



$this->file->ftpdel(FILE)

This function lets you to delete a remote FPT file.



$this->file->ftpcreatedir(DIR)

This function lets you create a remote FTP dir.



$this->file->ftpdeletedir(DIR)

This function lets you delete a remote FTP dir.



$this->file->ftplist(DIR)

This function returns an FTP dir content array.



ZIP helpers

Exception uses Zippy, an useful library to manage ZIP files into PHP.

You can access to it in every controller using $this->zip() or everywhere using $app->zip() (remember to include global istance compiling global $app;).

A full documentation of Zippy is here: https://github.com/alchemy-fr/Zippy

ZIP creation example

$app->zip->create(APP["storagedir"].'/ZipFileName.zip', array(
'images/logo.png' => APP["storagedir"].'/images/logo.png',
'images/background.jpg' => APP["storagedir"].'/images/background.jpg',
'app.js' => APP["storagedir"].'/js/application.js'
));


ZIP reader example

$archive = $app->zip->open(APP["storagedir"].'/UploadedZip.zip');
mkdir(APP["storagedir"].'/tmp');
$archive->extract(APP["storagedir"].'/tmp');


Do you need help?

Write me an e-mail: [email protected]