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>

Recommended Answers

All 5 Replies

what texts did you mean?

simply nothing.. it says that is not image. the file is image.

That's not nothing if that's what you see. That means that $image_size == TRUE is always true and you need to check what is returned in the variable. I don't think checking for true is the right approach.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.