Good on this occasion I want to make the user of my website login with the option of creating a photo album, and I can get the photo that the user uploads through the form with these codes:
HTML CODE:
<form action="album.php" enctype="multipart/form-data" method="post">
<input type="file" name="image">
<input type="submit" value="Subír" name="upload">
</form>
PHP CODE:
<?php
session_start();
$usuario = $_SESSION['user'];
if (isset($_POST['upload'])) {
$conexion = mysqli_connect('localhost','root','','image');
if (!$conexion) {
die("Error al conectarse a la base de datos.!". mysql_error());
}
else{
$directorio="tmpAlbums/$usuario";
$archivo=$_FILES['image']['tmp_name'];
$nombrearchivo=$_FILES['image']['name'];
move_uploaded_file($archivo, $directorio."/".$nombrearchivo);
$directorio=$directorio."/".$nombrearchivo;
mysqli_query($conexion, "INSERT INTO imagenes(imagen)
VALUES ('{$directorio}')");
}
}
?>
In the directory variable "$ directory", if it is set after the folder tmpAlbums I insert the variable of the user, it is say, as if it were a folder with the name of that user, but it is obvious that it did not work for me.
Well in question is that, I want to help me that when the user clicks to upload the photo that photo can be moved to the main destination folder plus the user's folder that I want to create to be stored there all your photos.
I wonder if you understand me anyway, in case of doubts I will be aware let me know if there is any doubt about my purpose and thanks in advance.!