Bonjour,
Je suis entrain de développer un module de recrutement sous zend, j'ai un petit souci au niveau d'ajout de candidatures, en effet j'ai réussi (l'upload de fichier), je les postuler lors d'une ancienne discussion, mais ce que je n'arrive pas à faire c'est la restriction du type et la taille de fichier( je veux donner la possibilité de télécharger que les fichiers words ou pdf)
si quelqu’un peut bien m'aider.
Merci d'avance .
ma fonction d'upload de fichier dans le contrôleur est la suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 public function ajoutCandidatureAction(){ $candidature = new RecrutementCandidature(); $offres = new RecrutementOffre(); $offresText = new RecrutementOffreText(); $translations = new thermidorTranslation(); $languages = new ThermidorLanguage(); $defaultLanguage = $languages->getDefaultLanguage(); $language = (isset($this->params['lang']) && $this->params['lang'] != '') ? $this->params['lang'] : $defaultLanguage; $listOffres = $offresText->getListOffresDisponibles(1,$language); $url = "{$this->params['module']}/index/ajout-candidature"; //Gestion des enregistrements de la table recrutement_candidature $tcandidature = array(); $tcandidature["candidatId"] = $this->params["candidatId"]; $tcandidature["offreId"] = $this->params["offreId"]; $tcandidature["langCode"] = $this->params["lang"]; $tcandidature["candidatNom"] = $this->params["candidatNom"]; $tcandidature["candidatPrenom"] = $this->params["candidatPrenom"]; $tcandidature["candidatEmail"] = $this->params["candidatEmail"]; $tcandidature["candidatAdresse"] = $this->params["candidatAdresse"]; $tcandidature["candidatCv"] = $this->params["candidatCv"]; $tcandidature["candidatLm"] = $this->params["candidatLm"]; $tcandidature["candidatDate"] = date("Y-m-d H:i:s"); // Upload de fichier $adapter = new Zend_File_Transfer(); $adapter->setDestination('D:\workspace\thermidor\public\upload'); $candidatCv = $adapter->getFileInfo(); $filePath = $adapter->getFileName(); $fileName = NULL; if($filePath) { $fileName = basename($filePath); } //echo $mime = $adapter->getMimeType()."<br>"; //echo $size = $adapter->getFileSize(); //Création des candidatures if($this->params["candidatId"] == ""){ if ($adapter->isUploaded()) { $adapter->receive(); $tcandidature["candidatId"] = NULL; $tcandidature["candidatCv"] = PUBLIC_UPLOAD.$fileName; if (!$fileName) { $messages = $adapter->getMessages(); echo implode("\n", $messages); $result = false; }else{ $candidature->insert($tcandidature); $result = true; } $url .= $result ? "/op/succes" : "/op/erreur" ; $this->gotoUrl($url); } } //En cas de retour d'actions sur l'index directement $message = ""; if (isset($this->params['op']) && $this->params['op'] == "succes") { //Succes $message = "Votre candidature a été enregistrée avec succès"; } else { //Ratage $message = "Votre candidature n'a pas été enregistrée"; } //Prépartaion de la vue $this->view->messageOperation = $message; $this->view->operation = $this->params['op']; $this->view->params = $this->params; $this->view->langCode = $this->params['lang']; $this->view->offreId = $this->params['offreId']; $this->view->listOffres = $listOffres; }
Partager