У меня есть следующий код ...Преобразование и сохранение загруженного изображения в PHP?
$current_full_path = realpath(dirname(__FILE__) . '/..');
$user_profile_picture_filename = $current_full_path . "/profile_pictures/" . $userid . ".jpg";
$user_profile_picture_submit = $_POST['user_profile_picture_submit'];
if (isset ($user_profile_picture_submit)) {
$user_profile_image = $_FILES['user_profile_image']['name'];
$temp_profile_picture = $_FILES['user_profile_image']['tmp_name'];
$profile_picture_extension_array = explode(".", $user_profile_image);
$profile_picture_extension_case_insensitive = end($profile_picture_extension_array);
$profile_picture_extension = strtolower($profile_picture_extension_case_insensitive);
if ($profile_picture_extension == "png") {
$temp_profile_picture_converted = imagecreatefrompng($temp_profile_picture);
} elseif ($profile_picture_extension == "bmp") {
$temp_profile_picture_converted = imagecreatefromwbmp($temp_profile_picture);
} elseif ($profile_picture_extension == "gif") {
$temp_profile_picture_converted = imagecreatefromgif($temp_profile_picture);
} elseif (($profile_picture_extension == "jpg") || ($profile_picture_extension == "jpeg")) {
$temp_profile_picture_converted = imagecreatefromjpeg($temp_profile_picture);
}
imagejpeg($temp_profile_picture_converted, $user_profile_picture_filename, '75');
imagedestroy($temp_profile_picture_converted);
}
То, что я пытаюсь сделать, это получить загруженную картинку, получить расширение, проверьте, какое расширение это, то на основе расширения, преобразовать его в формат JPEG с PHP, затем сохраните его как userid.jpg в каталоге «/ bar /». Однако ничего не спасено.
Я думаю, вы должны дать полный путь к переменной $ user_profile_picture_filename –
Полный путь означает? Разве это не полный путь? Эта переменная в ситуации, когда $ userid определена, будет иметь значение «http://111.111.1.111/foo/bar/111111.jpg» – Allenph
Задайте свой путь $ user_profile_picture_filename через мой ответ ниже. –