68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
<?php
|
|
class EnrichissementController extends Zend_Controller_Action
|
|
{
|
|
public function init()
|
|
{
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/enrichissement.js', 'text/javascript');
|
|
$this->view->headLink()->appendStylesheet('/themes/default/styles/enrichissement.css');
|
|
}
|
|
|
|
/**
|
|
* Enter description here ...
|
|
*/
|
|
public function indexAction(){}
|
|
|
|
public function fileformAction()
|
|
{
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/jquery.form.js', 'text/javascript');
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/jqueryprogressbar.js', 'text/javascript');
|
|
$this->view->assign('filesize', ini_get('upload_max_filesize'));
|
|
}
|
|
|
|
public function fileuploadAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
|
|
$path = realpath($config->data).'/clients';
|
|
if(!file_exists($path)) mkdir($path);
|
|
|
|
if ( isset($_FILES) && count($_FILES)==1 ){
|
|
$n = $_FILES['fichier']['name'];
|
|
$s = $_FILES['fichier']['size'];
|
|
$tmp_name = $_FILES['fichier']['tmp_name'];
|
|
$name = $_REQUEST['ref'];
|
|
|
|
$extValide = array('csv');
|
|
$extension = strrchr($n,'.');
|
|
$extension = substr($extension,1);
|
|
//@todo : vérifier l'extension du fichier
|
|
|
|
if (move_uploaded_file($tmp_name, $path.'/'.$name.'.'.$extension)){
|
|
echo "Uploadé !";
|
|
} else {
|
|
echo "Erreur : ".$_FILES['fichier']['error'];
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Etat de progression de l'upload du fichier
|
|
*/
|
|
public function fileprogressAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$request = $this->getRequest();
|
|
$key = $request->getParam('key', '');
|
|
if (!empty($key)) {
|
|
//$rep sera égal à false si la clef n'existe pas dans le cache apc
|
|
$rep = apc_fetch('upload_'.$key);
|
|
echo json_encode($rep);
|
|
}
|
|
}
|
|
|
|
|
|
} |