IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Zend_Form PHP Discussion :

upload de fichier


Sujet :

Zend_Form PHP

  1. #1
    Membre confirmé
    Femme Profil pro
    Ingénieur étude et développement
    Inscrit en
    Novembre 2009
    Messages
    125
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur étude et développement

    Informations forums :
    Inscription : Novembre 2009
    Messages : 125
    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 : 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
     
    <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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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

  2. #2
    Membre Expert
    Avatar de Nesmontou
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Septembre 2004
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2004
    Messages : 1 612
    Par défaut
    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

  3. #3
    Membre confirmé
    Femme Profil pro
    Ingénieur étude et développement
    Inscrit en
    Novembre 2009
    Messages
    125
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur étude et développement

    Informations forums :
    Inscription : Novembre 2009
    Messages : 125
    Par défaut
    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.

  4. #4
    Membre Expert
    Avatar de Nesmontou
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Septembre 2004
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2004
    Messages : 1 612
    Par défaut
    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.

  5. #5
    Membre confirmé
    Femme Profil pro
    Ingénieur étude et développement
    Inscrit en
    Novembre 2009
    Messages
    125
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur étude et développement

    Informations forums :
    Inscription : Novembre 2009
    Messages : 125
    Par défaut
    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.

  6. #6
    Membre confirmé
    Femme Profil pro
    Ingénieur étude et développement
    Inscrit en
    Novembre 2009
    Messages
    125
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur étude et développement

    Informations forums :
    Inscription : Novembre 2009
    Messages : 125
    Par défaut
    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 : 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
     
    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;
       }	
    }

  7. #7
    Membre confirmé
    Femme Profil pro
    Ingénieur étude et développement
    Inscrit en
    Novembre 2009
    Messages
    125
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur étude et développement

    Informations forums :
    Inscription : Novembre 2009
    Messages : 125
    Par défaut
    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.

  8. #8
    Membre confirmé
    Femme Profil pro
    Ingénieur étude et développement
    Inscrit en
    Novembre 2009
    Messages
    125
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur étude et développement

    Informations forums :
    Inscription : Novembre 2009
    Messages : 125
    Par défaut
    bonsoir,
    finalement j'ai retravaillé ma fonction d'upload donc ça marche bien, elle est comme suit:
    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
     
     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;
    	   }

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [FTP] Problème pour uploader un fichier
    Par Crazyblinkgirl dans le forum Entrée/Sortie
    Réponses: 10
    Dernier message: 07/01/2008, 22h21
  2. Upload de fichier par XMLHTTP
    Par Immobilis dans le forum ASP
    Réponses: 6
    Dernier message: 21/01/2005, 17h02
  3. upload de fichier
    Par 120 dans le forum ASP
    Réponses: 16
    Dernier message: 21/06/2004, 12h07
  4. Upload de fichiers sur un ftp
    Par Crazyblinkgirl dans le forum ASP
    Réponses: 10
    Dernier message: 20/06/2004, 11h55
  5. Upload de fichiers
    Par GDVL dans le forum ASP
    Réponses: 4
    Dernier message: 03/06/2004, 12h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo