hocam bu kodu deniyorum. verot kullanıyorum ajax-upload.php dosyasında.
ama resimi dizine yüklemiyor sadece veritabanına kaydediyor dosya bilgilerini..
upload.php dosyası nasıl olmalı dizine yükleyebilmem için?
Aşağıdaki şekilde dizine yüklemeyi yapabilirsin;
$filename = uniqid() . "-" . time(); // 5dab1961e93a7-1571494241
$extension = pathinfo( $_FILES["Resim"]["name"], PATHINFO_EXTENSION );
$basename = $filename . "." . $extension; // 5dab1961e93a7_1571494241.jpg
$valid_ext = array('png','jpeg','jpg');
$source = $_FILES["Resim"]["tmp_name"];
$destination = "../../upload/{$basename}";
$file_extension = pathinfo($destination, PATHINFO_EXTENSION);
$file_extension = strtolower($file_extension);
if(in_array($file_extension,$valid_ext)){
compressImage($source,$destination,60);
}else{
$jsonResult->response = "warning";
$jsonResult->message = "Sadece PNG, JPG, JPEG uzantılı dosya yükleyebilirsiniz.";
echo json_encode($jsonResult);
die;
}Ayrıca bu kodda kullandığım compressImage fonksiyonu fotoğrafın boyutunu sıkıştırmaya yarıyor. Onu da kullanmak istersen fonksiyonu da ekliyorum. İstemezsen de o alanı düzenleyebilirsin.
function compressImage($source, $destination, $quality) {
$info = getimagesize($source);
if ($info['mime'] == 'image/jpeg')
$image = imagecreatefromjpeg($source);
elseif ($info['mime'] == 'image/gif')
$image = imagecreatefromgif($source);
elseif ($info['mime'] == 'image/png')
$image = imagecreatefrompng($source);
imagejpeg($image, $destination, $quality);
}