Skip to content

Commit

Permalink
Merge pull request #1158 from willkoua/test_module_upload
Browse files Browse the repository at this point in the history
amelioration du message d'erreur pour le systeme d'upload
  • Loading branch information
willkoua committed May 18, 2016
2 parents 85081e0 + b74b1bc commit 7bcfb62
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/Controller/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ public function administration($img = null)
$pathCar = WWW_ROOT . "img/carousel/";
$pathTV = WWW_ROOT . "img/tv/";
$request = $this->request;
print_r($img);

if (is_file($pathCar . $img)) {
unlink($pathCar . $img);
Expand All @@ -575,25 +576,30 @@ public function administration($img = null)
$fileName = $image['name'];
$dim = null;

if (!empty($image['tmp_name']) && $image['type'] == 'image/png') {
$dim = getimagesize($image['tmp_name']);
print_r($image);
if (!empty($image['tmp_name'])) {
if ($image['type'] == 'image/png') {
$dim = getimagesize($image['tmp_name']);

if ($dim[0] >= 1920 && $dim[1] >= 1080) {
if ($hidden == 'car') {
move_uploaded_file($image['tmp_name'], $pathCar . $fileName);
}
if ($hidden == 'tv') {
if (preg_match("#^tv[1-5]$#", $fileName)) {
move_uploaded_file($image['tmp_name'], $pathTV . $fileName);
} else {
$this->Flash->error(__('rename image file (tv[1,2,3,4 or 5])'), ['key' => 'er_tv']);
if ($dim[0] >= 1920 && $dim[1] >= 1080) {
if ($hidden == 'car') {
move_uploaded_file($image['tmp_name'], $pathCar . $fileName);
}
if ($hidden == 'tv') {
if (preg_match("#^tv[1-5]$#", $fileName)) {
move_uploaded_file($image['tmp_name'], $pathTV . $fileName);
} else {
$this->Flash->error(__('rename image file (tv[1,2,3,4 or 5])'), ['key' => 'er_tv']);
}
}
} else {
$this->Flash->error(__('image file size incorrect'), 'er_gene');
}
} else {
$this->Flash->error(__('image file size incorrect'), 'er_gene');
$this->Flash->error(__('the format is not good'), 'er_gene');
}
} else {
$this->Flash->error(__('Error'), 'er_gene');
$this->Flash->error(__('no file transfer'), 'er_gene');
}
}
//fin gestion du carousel
Expand Down

0 comments on commit 7bcfb62

Please sign in to comment.