AlexanderOs Posted February 3, 2016 Share Posted February 3, 2016 (edited) Bonjour j'aurais besoin de quelque conseille pour géré un upload d'image multiples. Jusqu'ici j'ai dans mon renderFrom le bouton upload qui permet l'upload d'une seul image: array( 'type' => 'file', 'label' => $this->l('Select a file'), 'name' => 'fileUpload', 'desc' => $this->l('Banner picture. Extension allowed: jpeg, png, jpg, gif.'), 'lang' => true, 'desc' => $this->l(sprintf('Maximum image size: %s.', ini_get('upload_max_filesize'))) ), Je récupère au submit comme ceci if (isset($_FILES['fileUpload']) && is_uploaded_file($_FILES['fileUpload']['tmp_name'])) { if ($error = ImageManager::validateUpload($_FILES['fileUpload'], (Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 * 1024))) $output .= $this->displayError($error); if (!$output) { $upload_path = $this->local_path.'views/img/'; $pathinfo = pathinfo($_FILES['fileUpload']['name']); do $uniqid = sha1(microtime()); while (file_exists($upload_path.$uniqid.'.'.$pathinfo['extension'])); if (!copy($_FILES['fileUpload']['tmp_name'], $upload_path.$uniqid.'.'.$pathinfo['extension'])) $output .= $this->displayError($this->l('File copy failed')); @unlink($_FILES['file']['tmp_name']); if ($IMAGE_IMG && file_exists($upload_path.$IMAGE_IMG)) @unlink($upload_path.$IMAGE_IMG); $IMAGE_IMG = $uniqid.'.'.$pathinfo['extension']; } } Je voudrais rajouter deux bouton upload pour deux images en plus comment pourai-je fair. Edited February 5, 2016 by AlexanderOs (see edit history) Link to comment Share on other sites More sharing options...
AlexanderOs Posted February 4, 2016 Author Share Posted February 4, 2016 Le plus Logic ça serait d'utilisé un tableau Multi dimensionnel sur le "name" => fileUpload[] et de faire le trie à la sortie. array( 'type' => 'file', 'label' => $this->l('Select a file'), 'name' => 'fileUpload[]', 'desc' => $this->l('Banner picture. Extension allowed: jpeg, png, jpg, gif.'), 'lang' => true, 'desc' => $this->l(sprintf('Maximum image size: %s.', ini_get('upload_max_filesize'))) ), Mais si je fait ça le champ upload ne fonctionne pas, par contre si j'utilise de simple input directement en html cela fonction donc je pence que cela doit coincé au niveau des helpers. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now