uploadify를 사용하고 있습니다.하지만 업로드 된 파일의 이름을 바꾸는 PHP를 편집하는 방법이 너무 명확하지 않습니다.Uploadify - 파일 이름 바꾸기
기본적으로 사용자는 최대 4 개의 파일을 업로드 할 수 있으며 이름은 1-img-1, 1-img-2, 1-img-3, 1-img-4와 같이 지정해야합니다. id (POST를 통해 액세스 할 수 있음).
여기 uploadify PHP 스크립트는 다음과 같습니다
<?php
/*
UploadiFive
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
*/
// Set the uplaod directory
$uploadDir = '/img/listing_images/';
// Set the allowed file extensions
$fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // Allowed file extensions
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES) && $_POST['token'] == $verifyToken) { $i++;
$tempFile = $_FILES['Filedata']['tmp_name'];
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . $uploadDir;
$targetFile = $uploadDir . $_FILES['Filedata']['name'];
// Validate the filetype
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array(strtolower($fileParts['extension']), $fileTypes)) {
// Save the file
move_uploaded_file($tempFile, $targetFile);
echo 1;
} else {
// The file type wasn't allowed
echo 'Invalid file type.';
}
}
?>
누군가가 내가 업로드 된 파일의 이름을 바꿉니다 얼마나 나를 보여주기 위해 도움이 될 수 있다면 그냥 궁금?
귀하의 스크립트는 특히'$ uploadDir'이 문서 루트 내에 있다면 서버의 완전한 손상을 허용 할 것입니다. 당신의 "보안"은 아무것도 아닙니다. 사용자 제공 파일 이름에 의한 필터링은 ** 충분하지 않습니다 **. –