Skip to content

Instantly share code, notes, and snippets.

@dev-armando
Created November 2, 2021 04:50
Show Gist options
  • Save dev-armando/2c6fe5758eef7e129601ac52489aac0b to your computer and use it in GitHub Desktop.
Save dev-armando/2c6fe5758eef7e129601ac52489aac0b to your computer and use it in GitHub Desktop.
Funcion para subir una imagen
<?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