Fonction copy() et register_globals

Philippe C -  
 Philippe C -
voici concrètement ce qui se passe :
//un form et la fonction copy()


// photo.php
<form method="post" action="photo.php" enctype="multipart/form-data">
<input type="file" name="photo" class="formulaire">
<input type="submit" value="send" name="photo_send">
</form>

<?
if ($_POST["photo_send"]){
$photo=$_FILES["photo"];
copy($photo, "photos/$photo_name");
}


// voici l'erreur

Warning: copy(Array): failed to open stream: No such file or directory in c:\program files\easyphp1-7\www\menu\photo.php on line 27.


Comment faire cohabiter la fonction copy() et une variable, envoyée avec register_globals à off, de type $_FILES["photo"] ?

Y a-t-il une autre fonction de copy compatible?

Une astuce pour contourner le pb ?
A voir également:

2 réponses

Taboujr Messages postés 507 Statut Membre 117
 
Essaie un truc de ce genre :
if (array_key_exists ('photo', $_FILES) && is_file($_FILES['photo']['tmp_name'])) {
  copy($_FILES['photo']['tmp_name'],'./photos/'.$_FILES['photo']['name']);
} else {
  echo 'Fichier non transmis !';
}

Ca devrait fonctionner.

$_FILES contient pour chaque fichier uploadé un tableau qui contient toutes les infos relatives au fichier. Donc la variable $photo est un tableau, c'est pour cela que la fonction copy() a eu du mal puisqu'elle a besoin de chaînes de caractères.

.:: TaBou JuNioR ::.
J'ai des questions à toutes vos réponses. [W. Allen]
0
Philippe C
 
ok resolu avec :

$_FILES['photo']['tmp_name']
$_FILES['photo']['name']
$_FILES['photo']['size']

il faut le savoir! si ça peut servir à d'autre :)

Bien vu Taboujr
merci pour ta réponse.
0