im CMS gelişmekte.
Tablo istemcileri birçok alanlarını içeren ve bunlardan biri görüntü başlık olduğunu.
Kullanıcı bir dosyayı (görüntü) yüklediğinde dosya ortak klasör içinde saklanır.
Görüntü başlık alanı dosyanın son adını alır ve tabloda depolar.
Kullanıcı bilgilerini güncellemek istediğinde sorunudur. Kullanıcı görüntüyü değiştirmek istemiyor ise o "güncelleştirme" tıkladığında, görüntü başlık alanı boş, yani görüntüye yol boş olur ve artık o sadece gösteri (görüntü yok).
ive yapmaya çalışıyor ne heres:
HTML Form:
<p>
<label for="image_caption">Image Caption:</label>
<input name="image_caption" id="image_caption" type="text" class="formbox" size="60" disabled="disabled" value="<?php echo htmlentities($row['image_caption']); ?>" />
</p>
<p>
<label for="image">Insert image:</label>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" />
<input type="file" name="image" id="foto" value="<?php echo htmlentities($row['image_caption']); ?>"/>
</p>
<p>
<?php
if($row['image_caption']!= ""){
?>
<img src="../images/clientes/<?php echo $row['image_caption'];?>" width="194" height="145" title="Imagem cliente" class="floatright"/>
<?php
}else{
?>
<img src="../images/sem_imagem.gif" width="194" height="145" title="Imagem não disponível" class="floatright"/><br />
<?php
}
?>
</p>
<p>
<input type="submit" name="update" value="Update" />
<input name="cliente_id" type="hidden" value="<?php echo $row['codigo']; ?>" />
</p>
Ve şimdi yükleme PHP kodu (i u göstermek istedim sadece takılı kodunu ive):
// This checks if the file input is empty, and if it is, insert the value from the table that was previously inserted
if(empty($_FILES['image']['name'])){
$image_caption = $row['image_caption'];
}else{
$image = str_replace(' ', '_', $_FILES['image']['name']);
// move the file to the upload folder and rename it
move_uploaded_file($_FILES['image']['tmp_name'],UPLOAD_DIR.$foto);
$image_caption = $image;
}