Created
November 2, 2021 04:50
-
-
Save dev-armando/2c6fe5758eef7e129601ac52489aac0b to your computer and use it in GitHub Desktop.
Funcion para subir una imagen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function upload_image($destination_dir, $name_media_field, $intfecha){ | |
$tmp_name = $_FILES[$name_media_field]['tmp_name']; | |
if (is_dir($destination_dir) && is_uploaded_file($tmp_name)) { | |
$img_file = strtolower(str_replace(" ", "", $_FILES[$name_media_field]['name'])); | |
$img_type = $_FILES[$name_media_field]['type']; | |
if (((strpos($img_type, "gif") || strpos($img_type, "jpeg") || strpos($img_type, "jpg")) || strpos($img_type, "png"))) { | |
if (move_uploaded_file($tmp_name, $destination_dir . '/' . $intfecha . $img_file)) return true; | |
} | |
} | |
return false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment