I have a problem in uploading a picture using forms and display it on other page , the basic problem is I can't found the picture on the path where I save it : this is the form.php
<form role="form" id="equipe" action="editEquipe.php" method="get">
<div class="box-body">
<div class="form-group">
<label for="id_equipe">id Equipe</label>
<input type="text" class="form-control" id="id_equipe" name="id_equipe">
</div>
<div class="form-group">
<label for="drapeau">Télécharger le logo</label>
<input type="file" id="logo" name="logo">
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<button type="submit" value="" class="btn btn-primary">Modifier</button>
</div>
</form>
and this my action.php ,
if(isset($_GET['id_equipe']) && isset($_GET['logo']))
{
$id_equipe= $_GET['id_equipe'];
$logo = $_GET['logo'];
$imgname = "logo_".$id_equipe;
$logoImage=$imgname.".png";
$link = "http://.../LogoImages/".$imgname.".png";
if ($conn->connect_error) {
$response["error"] = -1;
$response["message"] = "cannot connect to the server please try again";
}
else
{
$sql = "UPDATE equipe set
nomEquipe='$nom_equipe',
logoEquipe=' $link',
idChampionnat='$nom_championnat'
where idEquipe='$id_equipe' ";
$updatedispo = $conn->query(sprintf($sql));
if($updatedispo)
{
$imsrc = base64_decode($logoImage);
$path ="http://.../LogoImages/".$imgname.".png";
$path = str_replace('\/','/',$path);
$fp = fopen($path, 'wb');
var_dump($fp);
if(is_readable($fp)) echo 'readable ';
else echo "no redable ";
if(is_writable($fp)) echo 'writable ';
else echo "no writable";
fwrite($fp, $logoImage);
// var_dump($fp);
fclose($fp);
$response["error"] = 0;
$response['picture'] = $path;
$response['message'] = "Image uploaded in ".$path;
$response['id_image'] = $id_equipe;
$response["message"] = " equipe updated";
}
else
{
$response["error"] = -1;
$response["message"] = "error requete";
}
}
}
else
{
$response["error"] = 100;
$response["message"] = "Some params are missing";
}
echo json_encode($response);
?>
Pleaaase help me
Aucun commentaire:
Enregistrer un commentaire