Я использую функцию uploadify в веб-проекте, и я не являюсь особенно php whiz, поэтому я стараюсь понять, почему следующие результаты в загруженном изображении без действительного расширения. Я получаю «1-профиль» без расширения .jpg. Может ли кто-нибудь пролить свет?Загрузить отсутствующее расширение файла
<?php
/*
UploadiFive
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
*/
// Set the uplaod directory
$uploadDir = '/img/profiles/';
// 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) {
rename($_FILES['Filedata']['name'], $_POST['user_id'].'-profile');
$tempFile = $_FILES['Filedata']['tmp_name'];
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . $uploadDir;
$targetFile = $uploadDir .$_POST['user_id']. '-profile.'. strtolower($fileParts['extension']);
// 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.';
}
}
?>
Вы говорите, что вы получаете '1-image' без расширения пока код вы предоставили не удаленно создать это имя файла, я немного запутался , –
Извините - я имею в виду 1-профиль –