Précédent   Forum des professionnels en informatique > PHP > Outils > Zend > Zend Framework > Zend_Form
Zend_Form Forum d'entraide pour le composant Zend_Form du Zend Framework (création de formulaires, helpers, AJAX etc.). Avant de poster -> FAQ Zend_Form.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 23/05/2011, 11h10   #1
Membre à l'essai
 
Femme
Développeur Web Junior
Inscription : novembre 2009
Messages : 124
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Développeur Web Junior

Informations forums :
Inscription : novembre 2009
Messages : 124
Points : 22
Points : 22
Par défaut upload de fichier

Bonjour je suis débutante et je souhaite réaliser sous zend 1.0.0, un formulaire html pour uploader un fichier sur le serveur. Pour le formaulire, il n'y a pas trop de probleme, il est défini dans une vue, mais c'est pour la fonction qui est codé dans le controlleur ou j'ai du mal...

Pouvez-vous m'aider.
Merci
le code de la vue est le suivant
Code :
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
 
<form class="formulaire" name="frmSavePage" id="frmSavePage" method="post" action="/recruthor/index/ajout-candidature/lang/<?php echo $this->langCode;?>/offreId/<?php echo $this->offreId; ?>" enctype="multipart/form-data" >
	<div class="menu-box"></div>
		<div>
			<div class="form-label-cand"><?php echo $this->infoCand->translateReturned; ?></div>
			<div class="clear-both"></div>
			<div class="input-label"><?php echo $this->nom->translateReturned; ?> <span class="mandatory-star"> * </span></div>
			<div class="input-field">
				<input type="text" class="input-label" id="candidatNom" name="candidatNom" 
						value="<?php echo $this->candidat->candidatNom; ?>"  />
			</div>
			<div class="clear-both"></div>
			<div class="input-label"><?php echo $this->prenom->translateReturned; ?><span class="mandatory-star"> * </span></div>
			<div class="input-field">
				<input type="text" class="input-label" id="candidatPrenom" name="candidatPrenom" 
						value="<?php echo $this->candidat->candidatPrenom; ?>"  />
			</div>
			<div class="clear-both"></div>
			<div class="input-label"><?php echo $this->email->translateReturned; ?><span class="mandatory-star"> * </span></div>
			<div class="input-field">
			<input type="text" class="input-label" id="candidatEmail" name="candidatEmail" 
						value="<?php echo $this->candidat->candidatEmail; ?>"  />
			</div>
			<div class="clear-both"></div>			
			<div class="input-label"><?php echo $this->adresse->translateReturned; ?><span class="mandatory-star"> * </span></div>
			<div class="input-field" style="width:615px;">
				<textarea   id="candidatAdresse" name="candidatAdresse"> 
							<?php echo $this->candidat->candidatAdresse; ?></textarea>
			</div>				
			<div class="clear-both"></div>
			<div class="input-label" id="candidatCv"><?php echo $this->Cv->translateReturned; ?><span class="mandatory-star"> * </span></div>
			<div class="input-field">
				<input type="file"  class="input-label" id="candidatCv" name="candidatCv" 
						value="<?php echo $this->candidat->candidatCv; ?>"/>
			</div>
			<div class="clear-both"></div>			
			<div class="input-label"><?php echo $this->lettreM->translateReturned; ?><span class="mandatory-star"> * </span></div>
			<div class="input-field" style="width:615px;">
				<textarea  id="candidatLm"
							name="candidatLm"><?php echo $this->candidat->candidatAdresse; ?></textarea>
			</div>				
			<script type="text/javascript">
				CKEDITOR.replace( 'candidatLm', 
						{
							toolbar : 'FullToolbar',
							// Load the German interface.
							language: '<?php echo $this->defaultLanguage; ?>'
						}								
					);
			</script>
			<div class="clear-both">&nbsp;</div>			
			<div class="input-label">&nbsp;</div>
			<div class="input-button"><button class="boutton-submit"><?php echo $this->ajoutCand->translateReturned; ?></button></div>
		</div>
	</form>
le code du controleur est le suiant ( le bout de code de l'upload)
Code :
1
2
3
4
5
6
7
 
// Upload de fichier
		   if( !empty($_FILES['candidatCv']) ) {
			  $fichier_temp = $_FILES['candidatCv']['tmp_name'];
			  $cv = $_FILES['candidatCv']['name'];
			  move_uploaded_file($_SERVER['DOCUMENT_ROOT'].'/thermidor/upload/'.$cv);
		  }
l'erreur qui est affichée est la suivante:

Warning: move_uploaded_file() expects exactly 2 parameters, 1 given in D:\workspace\thermidor\application\modules\recruthor\controllers\indexController.php on line 639
nassing est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/05/2011, 11h45   #2
Modérateur
 
Avatar de Nesmontou
 
Homme Benjamin PREVOT
Architecte de système d'information
Inscription : septembre 2004
Messages : 1 568
Détails du profil
Informations personnelles :
Nom : Homme Benjamin PREVOT
Âge : 30
Localisation : France, Nord (Nord Pas de Calais)

Informations professionnelles :
Activité : Architecte de système d'information
Secteur : Finance

Informations forums :
Inscription : septembre 2004
Messages : 1 568
Points : 2 493
Points : 2 493
Bonjour,

Le problème vient de ton utilisation de la fonction move_uploaded_file : comme l'indiques le message d'erreur, tu ne passes qu'un seul paramètre alors que 2 sont nécessaires.

Voici le lien vers la documentation officielle : http://fr2.php.net/manual/fr/functio...oaded-file.php
__________________
Si vous ne pouvez expliquer un concept à un enfant de six ans, c'est que vous ne le comprenez pas complètement. Albert EINSTEIN

F.A.Q. : Java, PHP, (X)HTML / CSS

N'oubliez pas de cliquer sur le bouton Résolu en bas de page quand vous avez obtenu une solution à votre problème
Nesmontou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/05/2011, 16h42   #3
Membre à l'essai
 
Femme
Développeur Web Junior
Inscription : novembre 2009
Messages : 124
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Développeur Web Junior

Informations forums :
Inscription : novembre 2009
Messages : 124
Points : 22
Points : 22
Oui j'avais compris qu'il me manquer un paramétré mais même si, je vois que ce bout de code ne marche pas.
Merci de m'orienter , ou de me donner une autre solution.
nassing est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 24/05/2011, 01h34   #4
Modérateur
 
Avatar de Nesmontou
 
Homme Benjamin PREVOT
Architecte de système d'information
Inscription : septembre 2004
Messages : 1 568
Détails du profil
Informations personnelles :
Nom : Homme Benjamin PREVOT
Âge : 30
Localisation : France, Nord (Nord Pas de Calais)

Informations professionnelles :
Activité : Architecte de système d'information
Secteur : Finance

Informations forums :
Inscription : septembre 2004
Messages : 1 568
Points : 2 493
Points : 2 493
Bonjour,
Citation:
Envoyé par nassing Voir le message
Merci de m'orienter , ou de me donner une autre solution.
Eh bien il faut passer 2 paramètres à cette fonction

As-tu bien lu la documentation officielle (cf. lien de mon post précédent) ?

Un exemple y est d'ailleurs présent.

Tu pourras aussi trouver pas mal de discussions au sujet de cette fonction en faisant une recherche sur le forum.
__________________
Si vous ne pouvez expliquer un concept à un enfant de six ans, c'est que vous ne le comprenez pas complètement. Albert EINSTEIN

F.A.Q. : Java, PHP, (X)HTML / CSS

N'oubliez pas de cliquer sur le bouton Résolu en bas de page quand vous avez obtenu une solution à votre problème
Nesmontou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/05/2011, 15h59   #5
Membre à l'essai
 
Femme
Développeur Web Junior
Inscription : novembre 2009
Messages : 124
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Développeur Web Junior

Informations forums :
Inscription : novembre 2009
Messages : 124
Points : 22
Points : 22
est ce que quelqu'un peut bien m'orienter vers une méthode à appliquer pour uploader en Zend, j'ai lu pas mal de tutos mais je n'arrive pas à insérer le chemin des fichiers uploadé dans la BDD.
nassing est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/05/2011, 17h24   #6
Membre à l'essai
 
Femme
Développeur Web Junior
Inscription : novembre 2009
Messages : 124
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Développeur Web Junior

Informations forums :
Inscription : novembre 2009
Messages : 124
Points : 22
Points : 22
je vous joins la fonction de mon contrôleur, en fait le fichier se charge dans la dossier upload par contre il ne s’insère pas dans la base de donnée. donc du coup pas d'ajout de candidature.
Code :
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
 
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);
       $adapter = new Zend_File_Transfer();
 
		$adapter->setDestination('D:\workspace\thermidor\public\upload');
		//Gestion des enregistrements de la table recrutement_candidature
		$tcandidature					= array();
		$tcandidature["candidatId"]			= $this->params["candidatId"];
		$tcandidature["offreId"]				= $this->params["offreId"];
		$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");
 
		//Création des candidatures
		if($this->params["candidatId"] == ""){
			if (!$adapter->receive()) {	
 
				$tcandidature["candidatId"]	= NULL;     
				$result								= $candidature->insert($tcandidature);	
			    $messages = $adapter->getMessages();
			    echo implode("\n", $messages);
			}
		}
 
   		//Prépartaion de la vue
 
   		$this->view->params				= $this->params;
	   	$this->view->langCode				= $this->params['lang'];
		$this->view->offreId				= $this->params['offreId'];
	   	$this->view->listOffres 				= $listOffres;
   }	
}
nassing est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/05/2011, 10h44   #7
Membre à l'essai
 
Femme
Développeur Web Junior
Inscription : novembre 2009
Messages : 124
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Développeur Web Junior

Informations forums :
Inscription : novembre 2009
Messages : 124
Points : 22
Points : 22
Ce que je n'arrive pas à faire c'est la récupération du chemin du fichier pour pouvoir l'insérer dans la base de données.
nassing est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/05/2011, 13h42   #8
Membre à l'essai
 
Femme
Développeur Web Junior
Inscription : novembre 2009
Messages : 124
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Développeur Web Junior

Informations forums :
Inscription : novembre 2009
Messages : 124
Points : 22
Points : 22
bonsoir,
finalement j'ai retravaillé ma fonction d'upload donc ça marche bien, elle est comme suit:
Code :
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
 
 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);
		//Gestion des enregistrements de la table recrutement_candidature
		$tcandidature							= array();
		$tcandidature["candidatId"]				= $this->params["candidatId"];
		$tcandidature["offreId"]				= $this->params["offreId"];
		$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(); 
		$name = $adapter->getFileName();
		//Création des candidatures
		if($this->params["candidatId"] == ""){
			if ($adapter->isUploaded()) {
			 	$adapter->receive();
				$tcandidature["candidatId"]		= NULL;      
				$tcandidature["candidatCv"]		= $name;
				$result							= $candidature->insert($tcandidature);
					if (!$adapter->receive($tcandidature["candidatCv"])) {		
					    $messages = $adapter->getMessages();
					    echo implode("\n", $messages);
					}
			}
		}	
   		//Prépartaion de la vue
 
   		$this->view->params						= $this->params;
	   	$this->view->langCode					= $this->params['lang'];
		$this->view->offreId					= $this->params['offreId'];
	   	$this->view->listOffres 				= $listOffres;
	   }
nassing est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 15h05.


 
 
 
 
Partenaires

Hébergement Web