Php'de Birden Fazla Dosya Yükleme (1 Viewer)

Joined
Jul 2, 2018
Credits
11
Rating - 0%
index.php
Code:
<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>Çoklu Dosya yükle</title>
  </head>
  <body>
<form method="post" action="process.php">
<input type="file" name="image[]" multiple="multiple" >
<p align="center"><button type="submit" class="btn btn-warning" id="butsave">Submit<span class="glyphicon glyphicon-send"></span></button></p>
</form>
</body>
</html>
[CODE] 

proje.php

[CODE]
<?php
$output_dir = "upload/";/* Yüklenecek Yer */
$fileCount = count($_FILES["image"]['name']);
for($i=0; $i < $fileCount; $i++)

{
$RandomNum = time();

$ImageName = str_replace(' ','-',strtolower($_FILES['image']['name'][$i]));
$ImageType = $_FILES['image']['type'][$i]; /*"image/png", image/jpeg etc.*/ Farklı türlerde olabilir

$ImageExt = substr($ImageName, strrpos($ImageName, '.'));
$ImageExt = str_replace('.','',$ImageExt);
$ImageName = preg_replace("/\.[^.\s]{3,4}$/", "", $ImageName);
$NewImageName = $ImageName.'-'.$RandomNum.'.'.$ImageExt;

$ret[$NewImageName]= $output_dir.$NewImageName;

/* Try to create the directory if it does not exist */
if (!file_exists($output_dir . $last_id))
{
@mkdir($output_dir . $last_id, 0777);
}

move_uploaded_file($_FILES["image"]["tmp_name"][$i],$output_dir.$last_id."/".$NewImageName );

/*$insert_img = "insert into `category_images` SET `category_ads_id`='".$category_ads_id_image."', `image`='".$NewImageName."'";
$result = $dbobj->query($insert_img);*/
}

echo "Dosya Başarılı bir şekilde yüklendi";
?>
 

Users who are viewing this thread

Top