Please help me with this...
I cannot insert pictures into the folder and it is not saving in the database
But it creates album folder.
Thanks
$albumname = addslashes($_POST['albumname']);
$target_path = "Gallery/images/".$albumname."/";
@$imagename = basename($_FILES['image']['name']);
@$target_path = $target_path . $imagename;
$file = $_FILES['image']['tmp_name'];
//@$image = addslashes(file_get_contents($file));
$album_target = "Gallery/images/".$albumname;
@$image_size = getimagesize($file);
$sql = "INSERT INTO gallery (album_name, albumartname, datetimeposted) VALUES ('$albumname', '', NOW())";
$data = nl2br($data);
$error = "";
//conditions
if(isset($_POST['addalbum']))
{
if(empty($albumname))
{
$error = '<div class="error_message">Please enter the Album Name</div>';
}
else if (!$file)
{
$error = '<div class="error_message">Please select an image</div>';
}
else if (!mkdir($album_target,0777))
{
$error = "Sorry, there was problem in creating your folder.";
}
else if($image_size == TRUE)
{
$error = '<div class="error_message">That is not an image.</div>';
}
else if(!move_uploaded_file($file, $target_path))
{
$error = "Sorry, there was a problem uploading your file.";
}
else
{
$result = mysql_query($sql) or die ("Error Saving the Information");
$error = "Success";
}
}
this is my form
<form method="post" enctype="multipart/form-data">
<table width="50%" cellpadding="5" cellspacing="2" align="center" border="1" class="event">
<th colspan="2" class="heading">Add Data</th>
<tr class="data">
<td>Album Name: </td>
<td><input type="text" name="albumname" size="90" value="<?php echo $albumname ?>"/></td>
</tr>
<tr class="data">
<td>Image: </td>
<td><input type="file" name="image[]" multiple="multiple" /></td>
</tr>
<tr>
<td colspan="2" align="right" class="data"><input type="button" name="back" value="Back" onclick="window.history.go(-1)" /><input type="submit" name="addalbum" value="Add" /></td>
</tr>
</table>
<center>
<label><?php echo $error ?></label>
</center>
</form>