<?php
$file = 'test.txt';
if(!file_exists($file)){
fopen($file,"w");
}
$getFile = file_get_contents($file);
if(isset($_POST['submit'])) {
$filetmp = $_FILES["image"]["tmp_name"];
$filename = $_FILES["image"]["name"];
$checker = getimagesize($filetmp);
if($checker !== false) {
$output = "success";
move_uploaded_file($filetmp, $filename);
file_put_contents($file, $filename);
}else{
$output = "error";
}
}
?>
<html>
<body>
<?php if(!empty($getFile)){ ?>
<img src="<?php echo file_get_contents($file); ?>"><br>
<p><?php echo 'https://'.$_SERVER['SERVER_NAME'].'/'.file_get_contents($file); ?></p>
<?php } ?>
<?php if(isset($output)){ ?>
<script>
alert('<?php echo $output; ?>');
window.location.reload();
</script>
<?php } ?>
<form action="#" method="POST" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit" name="submit">
</form>
</body>
</html>
çok çok teşekkür ederim emek verip yazmışınız ben kendi kullandığım şablona uyarlıyamadım onun üzerinden yardımcı olabilir misiniz?
if (isset($_POST['playerlogoduzenle'])) {
if ($_FILES['player_logo']['size']>1048576) {
echo "Bu dosya boyutu çok büyük";
Header("Location:../player-ayarlar.php?durum=dosyabuyuk");
exit;
}
$izinli_uzantilar=array('jpg','gif','','png');
//echo $_FILES['ayar_logo']["name"];
$ext=strtolower(substr($_FILES['player_logo']["name"],strpos($_FILES['player_logo']["name"],'.')+1));
if (in_array($ext, $izinli_uzantilar) === false) {
echo "Bu uzantı kabul edilmiyor";
Header("Location:../player-ayarlar.php?durum=formathata");
exit;
}
$uploads_dir = '../../dimg';
@$tmp_name = $_FILES['player_logo']["tmp_name"];
@$name = $_FILES['player_logo']["name"];
$benzersizsayi4=rand(20000,32000);
$refimgyol=substr($uploads_dir, 6)."/".$benzersizsayi4.$name;
$bos = "0";
@move_uploaded_file($tmp_name, "$uploads_dir/$benzersizsayi4$name");
if(!$name){
$duzenle=$db->prepare("UPDATE player SET
player_logo=:logo");
$update=$duzenle->execute(array(
'logo' => $bos
));
Header("Location:../player-ayarlar.php?durum=ok");
}else{
$duzenle=$db->prepare("UPDATE player SET
player_logo=:logo");
$update=$duzenle->execute(array(
'logo' => $refimgyol
));
if ($update) {
$resimsilunlink=$_POST['eski_yol'];
unlink("../../$resimsilunlink");
Header("Location:../player-ayarlar.php?durum=ok");
} else {
Header("Location:../player-ayarlar.php?durum=no");
}
}
}