۱۳۹۶ خرداد ۲۸, ۰۴:۴۶ ب.ظ
(آخرین تغییر در ارسال: ۱۳۹۶ خرداد ۲۸, ۰۴:۴۸ ب.ظ توسط mohammad3250.)
کد:
<?php
$extensions = array('.jpg', '.jpeg','.JPG', '.JPEG');
$valid_extensions = '.jpg, .jpeg';
$extension = strrchr($_FILES['uploaded_file']['name'], '.');
if (!in_array($extension, $extensions))
{
die("Estensione Errore!");
}
//cartella principale di salvataggio
$target_path = "uploads/";
$dir=$target_path;
//ricavo la richiesta client e leggo
$target_path2 = $target_path . basename( $_FILES['uploaded_file']['name']);
$target = $target . basename( $_FILES['uploaded_file']['name']);
//tolgo l'estensione
$target_path2 = str_replace(".JPG", "/", $target_path2);
$target_path2 = str_replace(".jpg", "/", $target_path2);
$target_path2 = str_replace(".JPEG", "/", $target_path2);
$target_path2 = str_replace(".jpeg", "/", $target_path2);
//creo cartella con il nome del file
mkdir("$target_path2",0755);
$target_file_mod = imageExists($target,$target_path2);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path2 .$target_file_mod)) {
echo " The file ". $target_file_mod ." has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
چطور میتونم از مسیر آپلود عکس پوشه ای که با اسم عکس هم ایجاد میشه حذف کنم
مثال:
yourdomain.com/upload/ax/ax.png
به شکل ریر بشه
yourdomain.com/upload/ax.png