Gestion référence et idClient pour le nom du fichier
This commit is contained in:
parent
223eae4784
commit
53b30e39af
@ -4,8 +4,8 @@ class EnvoiController 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');
|
||||
$this->view->headScript()->appendFile('/scripts/enrichissement.js', 'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet('/styles/enrichissement.css');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,8 +15,8 @@ class EnvoiController extends Zend_Controller_Action
|
||||
|
||||
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->headScript()->appendFile('/scripts/jquery.form.js', 'text/javascript');
|
||||
$this->view->headScript()->appendFile('/scripts/jqueryprogressbar.js', 'text/javascript');
|
||||
$this->view->assign('filesize', ini_get('upload_max_filesize'));
|
||||
}
|
||||
|
||||
@ -25,27 +25,48 @@ class EnvoiController extends Zend_Controller_Action
|
||||
$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);
|
||||
$resquest = $this->getRequest();
|
||||
|
||||
if ( isset($_FILES) && count($_FILES)==1 ){
|
||||
$n = $_FILES['fichier']['name'];
|
||||
$s = $_FILES['fichier']['size'];
|
||||
$tmp_name = $_FILES['fichier']['tmp_name'];
|
||||
$name = $_REQUEST['ref'];
|
||||
$name = $resquest->getParam('ref', '');
|
||||
$idClient = $request->getParam('client');
|
||||
if (empty($name)) {
|
||||
echo "Référence non définie.";
|
||||
}
|
||||
|
||||
$extValide = array('csv');
|
||||
$extension = strrchr($n,'.');
|
||||
$extension = substr($extension,1);
|
||||
//@todo : vérifier l'extension du fichier
|
||||
if (empty($idClient)) {
|
||||
echo "Client non définie.";
|
||||
}
|
||||
|
||||
if (!empty($name) && !empty($idClient))
|
||||
{
|
||||
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
|
||||
$path = realpath($config->data).'/clients';
|
||||
if(!file_exists($path)) mkdir($path);
|
||||
|
||||
if (move_uploaded_file($tmp_name, $path.'/'.$name.'.'.$extension)){
|
||||
echo "Uploadé !";
|
||||
} else {
|
||||
echo "Erreur : ".$_FILES['fichier']['error'];
|
||||
if ( isset($_FILES) && count($_FILES)==1 ){
|
||||
$n = $_FILES['fichier']['name'];
|
||||
$s = $_FILES['fichier']['size'];
|
||||
$tmp_name = $_FILES['fichier']['tmp_name'];
|
||||
|
||||
$extValide = array('csv');
|
||||
$extension = strrchr($n,'.');
|
||||
$extension = substr($extension,1);
|
||||
//Vérifier l'extension du fichier
|
||||
if(!in_array($extension, $extValide)){
|
||||
echo "Extension de fichier incorrect !";
|
||||
} elseif (move_uploaded_file($tmp_name, $path.'/'.$name.'.'.$extension)){
|
||||
//@todo : Vérifier le format du fichier
|
||||
|
||||
|
||||
//@todo : Enregistrer dans la bdd
|
||||
|
||||
|
||||
echo "Uploadé !";
|
||||
} else {
|
||||
echo "Erreur : ".$_FILES['fichier']['error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user