Código
<!DOCTYPE html> <html lang="es" dir="ltr"> <head> <meta charset="utf-8"> <meta name="author" content="Diesan Romero"> <meta name="description" content="Sube tus imagenes de manera temporal"> <meta http-equiv="imagetoolbar" content="no"> <meta http-equiv="pragma" content="no-cache"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"> <link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.5.0/css/mdb.min.css" rel="stylesheet"> <link rel="stylesheet" href="src/styles.css"> </head> <body oncontextmenu="return false" ondragstart="return false" onselectstart="return false" onkeydown="return false"> <div class="container-fluid"> <div class="row justify-content-center mt-5"> </div> <div class="row justify-content-center mt-4"> <form action="index.php" method="post" enctype="multipart/form-data"> <div class="form"> <div class="row justify-content-center mt-1"> <div class="btn-group" role="group"> </div> </div> <div class="row justify-content-center mt-5"> <input type="file" name="imagen" id="imagen" class="input-file"> <label for="imagen" class="btn btn-lg btn-outline-black js-labelFile"> </label> <input type="submit" class="btn btn-lg btn-red" value="Subir Imagen"> </div> </div> </form> </div> </div> <?php if (!isset($_FILES['imagen']['tmp_name']) || !file_exists($_FILES['imagen']['tmp_name']) || !is_uploaded_file($_FILES['imagen']['tmp_name'])){ } else { $nombre = $_FILES['imagen']['name']; $tipo = $_FILES['imagen']['type']; $tamano = $_FILES['imagen']['size']; $tmpext=explode(".", $nombre); $extension = end($tmpext); $generado = md5($nombre.rand()).'.'.$extension; $nombre = substr($generado, 0,7); $carpetaImagenes = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'imagenes-momentaneas/imagenes'; if (!is_dir($carpetaImagenes)) { mkdir($carpetaImagenes, 0775); } if (!is_writable($carpetaImagenes)) { chmod($carpetaImagenes, 0775); } //Crea la carpeta Uploads $carpetaUploads = $carpetaImagenes.DIRECTORY_SEPARATOR.'uploads'; if (!is_dir($carpetaUploads)) { mkdir($carpetaUploads, 0775); } if (!is_writable($carpetaUploads)) { chmod($carpetaUploads, 0775); } if ($_FILES['imagen']['size'] != 0 && $_FILES['imagen']['type'] === 'image/jpeg' || $_FILES['imagen']['type'] === 'image/jpg' || $_FILES['imagen']['type'] === 'image/png' || $_FILES['imagen']['type'] === 'image/gif') { // Envia la imagen del directorio temporar al servidor move_uploaded_file($_FILES['imagen']['tmp_name'], $carpetaUploads.DIRECTORY_SEPARATOR.$nombre); // Path de donde va a estar la imagen ya subida $path = $carpetaUploads.DIRECTORY_SEPARATOR.$nombre; $enlace = 'http://localhost/imagenes/uploads/'.$nombre.; //echo "<img src='data:image/jpg;base64,".base64_encode(file_get_contents($path))."' />"; } } ?> </body> </html>
Alguna idea?