Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1136 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  Recuprer L'URL du fichier Uploader !!

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Recuprer L'URL du fichier Uploader !!

n°1762635
gerome44
Posté le 21-07-2008 à 16:27:12  profilanswer
 

Bonjour à tous !
 
J'ai mis en place une page d'upload qui marche niquel
 
quand le fichier est uploader il s'affiche ce méssage !
 
Fichier Swf envoyé avec succès
 
je voudrais donc en plus de cette phrase afficher :
 
Fichier Swf envoyé avec succès Votre jeux est disponible à cette adresse : http://monsite/upload/upload/Fichier.swf
 
vous l'avez compris les fichiers à uploader sont des jeux flash (.swf)
 
Voici le script actuel : Upload.php
 

Citation :

<?php
if ($_FILES['Filedata']['name'] && ($log = fopen('./upload.log', 'a') ) )
{
 $file = $_FILES['Filedata']['tmp_name'];
 $error = false;
 
 /**
 * THESE ERROR CHECKS ARE JUST EXAMPLES HOW TO USE THE REPONSE HEADERS
 * TO SEND THE STATUS OF THE UPLOAD, change them!
 *
 */
 
 if (!is_uploaded_file($file) || ($_FILES['Filedata']['size'] > 50 * 1024 * 1024) )
 {
  $error = '400 Bad Request';
 }
 
 fputs($log, ($error ? 'FAILED' : 'SUCCESS') . ' - ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ": {$_FILES[Filedata][name]} - {$_FILES[Filedata][size]} byte \n" );
 fclose($log);
 
 if ($error)
 {
  /**
  * ERROR DURING UPLOAD, one of the validators failed
  *
  * see FancyUpload.js - onError for header handling
  */
  header('HTTP/1.0 ' . $error);
  die('Error ' . $error);
 }
 else
 {
  move_uploaded_file($file, 'upload/'.$_FILES['Filedata']['name']);
 }
 die('Fichier Swf envoyé avec succès
 
 
 
 
 ');
 
}
?>
 


 
Voici le script actuel : index.php
 

Citation :

<html>
 
<body onload="document.getElementById('chargement').style.display = 'none'">
   <div id="chargement">Chargement de la page en cours ...</div>
 
<!--  ------------------  -->
<script type="text/javascript">
<!--
 
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
 
//-->
</script>
<!--  ------------------  -->
<body class="l_fr_FX" id="default" style="background-image: url(img/fond.gif);background-repeat: repeat;">
<link rel="shortcut icon" href="img/favico.ico" type="image/x-icon">
<!--  ------------------  -->
 
<head>
 <title>Micro.games ( Ajoutez le site à vos favoris en faisant Ctrl + D )</title>
<meta name="title" content="Micro.games">
<meta http-equiv="Content-type" content="text/html;charset=iso-8859-1">
<meta name="author" content="Gerome44">
<meta name="Identifier-URL" content="http://micro.games.free.fr">
<meta name="subject" content="Jeux flash">
<meta name="Reply-to" content="Gerome44@gmail.com">
<meta name="generator" content="Script edit">
<meta name="description" content="Site de jeux flash en ligne">
<meta name="abstract" content="Site de jeux flash en ligne">
<meta name="keywords" content="flash,jeux flash,gerome44,kclbm,jeux gratuit,jeux flash gratuit,">
<meta name="revisit-after" content="7 days">
<meta http-equiv="Content-Language" content="fr">
<meta name="language" content="fr">
<meta name="copyright" content="© micro.games">
<meta name="robots" content="Index,Follow,All">
</head>
 
<body>
 
<div align="center">
  <table border="20" cellpadding="0" cellspacing="0" width="50" bgcolor="#FFFF66">
    <tr>
      <td width="50"><div align="center"><object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#3,0,0,0" width="425" height="80">
 <param name="src" value="swf/micro.games.swf">
 <param name="quality" value="high">
 <embed src="swf/micro.games.swf" pluginspage="http://www.macromedia.com/shockwave/download/" type="application/x-shockwave-flash" width="425" height="80">
 </embed>
</object></div></td>
<div align="center">
     <tr>
      <td width="50"><marquee Class="Scroller" behavior="scroll" direction="left" width="100%" height="19" scrollamount="4" scrolldelay="0" onMouseOver="this.stop()" onMouseOut="this.start()"><font size="2" face="Arial, Helvetica, sans-serif"><strong><em>Bienvenue sur Micro-Games</em></strong><font color="#333399"><strong>, Le 1er site de jeux flash adapté à la psp !!</strong></font></font></marquee></td>
    </tr>
</div>
<div align="center">
 
</div>
<div align="center">
    <tr>
      <td width="50"><a href="http://www.prizee.com/?refer=Gerome442" target=_blank ><div align="center"><img src="img/jeux-gratuits-cadeaux-1.jpg" border=0 width=425 height=60 alt="Prizee : Jeux Gratuits et Cadeaux !" title="Prizee : Jeux Gratuits et Cadeaux !"></div></a></td>
    </tr>
 
</div>
<div align="center">
 
    <tr>
      <td width="50"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
 
 
 
<script type="text/javascript">
function ChangeStatut(formulaire) {
if(formulaire.regagree.checked == true) {formulaire.validation.disabled = false }
if(formulaire.regagree.checked == false) {formulaire.validation.disabled = true }
}
</script>
 
 
 
 
 
 
 
 
 
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 
 <title>digitarald.de  upload - Widget Birthplace</title>
 <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
 <script type="text/javascript" src="build.js"></script>
 <script type="text/javascript" src="swiff/Swiff.Base.js"></script>
 <script type="text/javascript" src="swiff/Swiff.Uploader.js"></script>
 <script type="text/javascript" src="js/FancyUpload.js"></script>
 
 
</head>
<body>
 
 
 <br><br>
 
 
  <form action="upload.php" method="post" id="photoupload2" enctype="multipart/form-data">
 
 
     <legend>&nbsp;&nbsp;&nbsp;Selectioner votre fichier format (.swf)<br><br></legend>
 
    <div class="label emph">
      &nbsp;&nbsp;&nbsp;<label for="photoupload2-filedata-1">
       
       
 
      </label>
      <input type="file" name="Filedata" id="photoupload2-filedata-1" />
     </div>
 
    </fieldset>
   </div>
 
<br><br>    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="javascript:ouvre_popup('Reglement-Swf.htm')">Lire le règlement<br><br></div></A>
 
<SCRIPT language="javascript">
   function ouvre_popup(page) {
       window.open(page,"nom_popup","menubar=no, status=no, scrollbars=no, menubar=no, width=600, height=700" );
   }
</SCRIPT>
   
<br><form action="" methed="post">
<p>&nbsp;&nbsp;&nbsp;<form action="" methed="post">
<p>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="regagree" value="valeur" onClick="ChangeStatut(this.form)" /> J'accepte le reglement</p>
<br>
<p><div align="center"<p>&nbsp;&nbsp;&nbsp;<input type="submit" name="validation" value="Envoyer" disabled /></p>
 
</div></p>
</form>
     
   </div>
  </form>
 </div><br>
 <script src="js/urchin.js" type="text/javascript"></script>
 <script type="text/javascript">
 _uacct = "UA-601848-2";
 urchinTracker();
 </script>
</body>
</html></td>
    </tr>
 
</div>
<div align="center">
 
   <tr><tr bgcolor="#FFFFFF" background="#FFFFFF">
      <td width="50">    <div align="center"><object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#3,0,0,0" width="100" height="60">
 <param name="src" value="swf/Retour.swf">
 <param name="quality" value="high">
 <embed src="swf/Retour.swf" pluginspage="http://www.macromedia.com/shockwave/download/" type="application/x-shockwave-flash" width="100" height="60">
 </embed>
</object></div></td>
    </tr>
 
</div>
<div align="center">
 
    <tr>
      <td width="50"><div align="center">Micro.games © 2008 KG production <b>( Favoris : Ctrl + D )</b></div></td>
    </tr>
 
</div>
</table>
</body>
 
</html>


 
Je vous avous que c'est un peu le bordel ^^
 
en passant j'ai remarquer que mon script accepte pas que les fichier .swf donc si vous savez comment changer sa ^^
 
 
Merci merci d'avance :)

mood
Publicité
Posté le 21-07-2008 à 16:27:12  profilanswer
 

n°1762890
Marty_McFl​y
Nan hé ho, d'accord?
Posté le 22-07-2008 à 09:44:53  profilanswer
 

ça se joue dans le premier fichier php
 

Code :
  1. <?php
  2. if ($_FILES['Filedata']['name'] && ($log = fopen('./upload.log', 'a') ) )
  3. {
  4. $file = $_FILES['Filedata']['tmp_name'];
  5. $error = false;
  6. /**
  7. * THESE ERROR CHECKS ARE JUST EXAMPLES HOW TO USE THE REPONSE HEADERS
  8. * TO SEND THE STATUS OF THE UPLOAD, change them!
  9. *
  10. */
  11. if (!is_uploaded_file($file) || ($_FILES['Filedata']['size'] > 50 * 1024 * 1024) )
  12. {
  13.   $error = '400 Bad Request';
  14. }
  15. fputs($log, ($error ? 'FAILED' : 'SUCCESS') . ' - ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ": {$_FILES[Filedata][name]} - {$_FILES[Filedata][size]} byte \n" );
  16. fclose($log);
  17. if ($error)
  18. {
  19.   /**
  20.   * ERROR DURING UPLOAD, one of the validators failed
  21.   *
  22.   * see FancyUpload.js - onError for header handling
  23.   */
  24.   header('HTTP/1.0 ' . $error);
  25.   die('Error ' . $error);
  26. }
  27. else
  28. {
  29.    $nomfichier = $_FILES['Filedata']['name'];
  30.    if( ereg("swf$",$nomfichier) ) { // Si le fichier a une extension .swf
  31.       move_uploaded_file($file, 'upload/'.$nomfichier);
  32.    }
  33.    else { // Sinon
  34.       die('Le texte que tu veux pour indiquer que le fichier n'est pas un .swf');
  35.    }
  36. }
  37. echo "Fichier Swf envoyé avec succès. Votre jeux est disponible à cette <a href='http://monsite/upload/upload/".$nomfichier."'>adresse</a>"
  38. }
  39. ?>


 
A tester pour le filtre sur les noms de fichier, j'ai pas essayé :(


Message édité par Marty_McFly le 22-07-2008 à 09:46:04

---------------
arg(z) = pi /2 donc z = i, moi je prends pas
n°1762942
gerome44
Posté le 22-07-2008 à 11:04:06  profilanswer
 

Merci pour ta réponse mais ça ne marche pas voici ce que ça donne :
 
Parse error: syntax error, unexpected T_IF in /mnt/104/sda/2/f/micro.games/upload/upload.php on line 2

n°1762945
Alisteroid
Posté le 22-07-2008 à 11:05:50  profilanswer
 

Rajoute "}" à la ligne 6, c'est bien beau de demander de l'aide mais quand on te donne un script, le minimum c'est d'essayer de le comprendre et de le corriger si possible.
Et ça m'étonnerait que son script marche sans que tu le modifie un minimum, à moins que ton input file soit nommé "'Filedata'", que ton fichier de log existe bien ...

 

Surtout qu'avec ce qu'on t'a donné on peut uploader n'importe quel type de fichier...

 


Message édité par Alisteroid le 22-07-2008 à 11:06:54
n°1762951
gerome44
Posté le 22-07-2008 à 11:11:05  profilanswer
 

j'ai rajouter mais cela ne marche toujours pas mon input est bien filedata et mon fichier log existe bien donc je ne comprend pas ce qui ne va pas !!
 
Merci quand meme de ton aide

n°1762954
gerome44
Posté le 22-07-2008 à 11:13:54  profilanswer
 
n°1762960
Marty_McFl​y
Nan hé ho, d'accord?
Posté le 22-07-2008 à 11:19:38  profilanswer
 

Code :
  1. <?php
  2. if ( $_FILES['Filedata']['name'] && ($log = fopen('./upload.log', 'a') ) ) {
  3. $file = $_FILES['Filedata']['tmp_name'];
  4. $error = false;
  5. }
  6. /**
  7. * THESE ERROR CHECKS ARE JUST EXAMPLES HOW TO USE THE REPONSE HEADERS
  8. * TO SEND THE STATUS OF THE UPLOAD, change them!
  9. *
  10. */
  11. if ( !is_uploaded_file($file) || ( $_FILES['Filedata']['size'] > 50 * 1024 * 1024 ) ) {
  12.   $error = '400 Bad Request';
  13. }
  14. fputs($log, ($error ? 'FAILED' : 'SUCCESS') . ' - ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ": {$_FILES[Filedata][name]} - {$_FILES[Filedata][size]} byte \n" );
  15. fclose($log);
  16. if ($error) {
  17. /**
  18. * ERROR DURING UPLOAD, one of the validators failed
  19. *
  20. * see FancyUpload.js - onError for header handling
  21. */
  22. header('HTTP/1.0 ' . $error);
  23. die('Error ' . $error);
  24. }
  25. else {
  26. $nomfichier = $_FILES['Filedata']['name'];
  27. if( ereg("swf$",$nomfichier) ) { // Si le fichier a une extension .swf
  28. move_uploaded_file($file, 'upload/'.$nomfichier);
  29. }
  30. else { // Sinon
  31. die("Le texte que tu veux pour indiquer que le fichier n'est pas un .swf" );
  32. }
  33. }
  34. echo "Fichier Swf envoyé avec succès. Votre jeux est disponible à cette <a href='http://monsite/upload/upload/".$nomfichier."'>adresse</a>"
  35. }
  36. ?>


 
ça ne marche pas ça?


---------------
arg(z) = pi /2 donc z = i, moi je prends pas
n°1763353
gerome44
Posté le 22-07-2008 à 19:18:00  profilanswer
 

non malheureusement :(
 
 
Parse error: syntax error, unexpected T_IF in /mnt/104/sda/2/f/micro.games/upload/upload.php on line 2
 
 
merci quand meme

n°1763585
Alisteroid
Posté le 23-07-2008 à 10:39:43  profilanswer
 

Code :
  1. <?php
  2. if ( $_FILES['Filedata']['name'] && ($log = fopen('./upload.log', 'a') ) )
  3. {
  4. $file = $_FILES['Filedata']['tmp_name'];
  5. $error = false;
  6. }
  7. /**
  8. * THESE ERROR CHECKS ARE JUST EXAMPLES HOW TO USE THE REPONSE HEADERS
  9. * TO SEND THE STATUS OF THE UPLOAD, change them!
  10. *
  11. */
  12. if ( !is_uploaded_file($file) || ( $_FILES['Filedata']['size'] > 50 * 1024 * 1024 ) )
  13. {
  14.   $error = '400 Bad Request';
  15. }
  16. fputs($log, ($error ? 'FAILED' : 'SUCCESS') . ' - ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ": {$_FILES[Filedata][name]} - {$_FILES[Filedata][size]} byte \n" );
  17. fclose($log);
  18. if ($error)
  19. {
  20. /**
  21. * ERROR DURING UPLOAD, one of the validators failed
  22. *
  23. * see FancyUpload.js - onError for header handling
  24. */
  25. header('HTTP/1.0 ' . $error);
  26. die('Error ' . $error);
  27. }
  28. else {
  29. $nomfichier = $_FILES['Filedata']['name'];
  30. if( ereg("swf$",$nomfichier) )
  31. { // Si le fichier a une extension .swf
  32.  move_uploaded_file($file, 'upload/'.$nomfichier);
  33. }
  34. else
  35. { // Sinon
  36.  die("Le texte que tu veux pour indiquer que le fichier n'est pas un .swf" );
  37. }
  38. }
  39. echo "Fichier Swf envoyé avec succès. Votre jeux est disponible à cette <a href='http://monsite/upload/upload/".$nomfichier."'>adresse</a>"
  40. ?>

n°1763596
Marty_McFl​y
Nan hé ho, d'accord?
Posté le 23-07-2008 à 10:50:55  profilanswer
 

effectivement, il y avait un } en trop a la fin.
 
Mis à part ça, j'ai la bigre impression que c'est codé assez salement: imagine que le fichier de log n'existe pas (comme l'a dit sebondus) -> un petit headers already sent des familles, ou bien que, pour une raison quelconque, le move_uploaded_file échoue: tu indiques que tout s'est bien passé, tu proposes meme une url pour DL le fichier alors qu'il n'existe meme pas...


Message édité par Marty_McFly le 23-07-2008 à 10:51:54

---------------
arg(z) = pi /2 donc z = i, moi je prends pas
mood
Publicité
Posté le 23-07-2008 à 10:50:55  profilanswer
 

n°1763599
Alisteroid
Posté le 23-07-2008 à 10:53:40  profilanswer
 

Et la vérification du type de fichier faite sur l'extension  [:jofission]

n°1763600
Marty_McFl​y
Nan hé ho, d'accord?
Posté le 23-07-2008 à 10:58:56  profilanswer
 

Code :
  1. <?php
  2. if ( isset($_FILES['Filedata']['name']) ) {
  3. $file = $_FILES['Filedata']['tmp_name'];
  4. $error = false;
  5. }
  6. $log = fopen('./upload.log', 'a');
  7. if ( !is_uploaded_file($file) || ( $_FILES['Filedata']['size'] > 50 * 1024 * 1024 ) || !$log) {
  8.     $error = '400 Bad Request';
  9. }
  10. else {
  11. fputs($log, ($error ? 'FAILED' : 'SUCCESS') . ' - ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ": {$_FILES[Filedata][name]} - {$_FILES[Filedata][size]} byte \n" );
  12. fclose($log);
  13. }
  14. if ($error) {
  15. header('HTTP/1.0 ' . $error);
  16. die('Error ' . $error);
  17. }
  18. else {
  19. $nomfichier = $_FILES['Filedata']['name'];
  20. if( $_FILES['Filedata']['type'] == 'application/x-shockwave-flash' ) { // Si le fichier a une extension .swf
  21.  if( move_uploaded_file($file, './upload/'.$nomfichier) ) {
  22.   echo "Fichier Swf envoyé avec succès. Votre jeux est disponible à cette <a href='http://monsite/upload/".$nomfichier."'>adresse</a>";
  23.  }
  24.  else { echo "Erreur lors de l'upload... il va falloir retenter"; }
  25. }
  26. else { // Sinon
  27.  die("Le texte que tu veux pour indiquer que le fichier n'est pas un .swf" );
  28. }
  29. }
  30. ?>


Message édité par Marty_McFly le 23-07-2008 à 11:19:17

---------------
arg(z) = pi /2 donc z = i, moi je prends pas

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  Recuprer L'URL du fichier Uploader !!

 

Sujets relatifs
[VB6] Récupérer un fichier image sur le web => Non résoluTelecharger un fichier zip sur internet
Recherche/suppression fichier batchVBA ouvrir fichier txt avec séparateurs
[Réglé] lire fichier log pendant qu'une application l'écrit[résolu] Lire un fichier de configuration
Probablement un problème de regexp....? (extraction d'URL)URL Rewriting de base...
importation fichier > tableau dans python[C] Manipulation de chaines dans un fichier
Plus de sujets relatifs à : Recuprer L'URL du fichier Uploader !!


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR