I have a MySQL
db, with 2 tables, albums and photos:
albums has id and name, photos has id, album_id, photo_name.
and I have the following script:
<?php
$albumsQuery = $mysqli->query( "SELECT `album_id`, `album_name` FROM `albums` ORDER BY `album_name` ASC" );
if( isset( $_FILES["albumPhoto"] ) )
{
move_uploaded_file( $_FILES["albumPhoto"]["tmp_name"], "photos/" .$_FILES["albumPhoto"]["name"] );
}
if( isset( $_POST["album_name"] ) )
{
$uploadQuery = $mysqli->query( "INSERT INTO `photos` ( `photo_id`, `photos`.`photo_id_album`, `photos`.`photo_name` )
VALUES ( NULL,'" . $mysqli->real_escape_string( $_POST["album_name"] ) . "','" . $mysqli->real_escape_string( $_FILES["albumPhoto"]["name"] ) . "' )" )
or die( $mysqli->error );
$upload = $uploadQuery->fetch_array( MYSQLI_ASSOC );
}
?>
The image is uploaded on disk, but I can't get the image name on DB.
Thanks in advanced.