Hi Friends,
I am using this code to upload image but it seems my call is not getting inside function. I put some echo commands for debugging. all I get output is after selecting file "hello entering function". but do not get other echo command print.
Neither insert command is executed.
Can you suggest what is wrong here.
<td><div align="left">Upload Image:(bmp,gif,jpg,png)</div></td>
<td><input name="uploadedimage" type="file" id="uploadedimage">
<input type="submit" name="uploadedimage" value="Upload Image" align="center"style="background-color: transparent;color:#F7F7F7;font-size:14px;font-weight:bold; border: none;text-decoration: underline;cursor: hand;cursor: pointer;">
<?php
if(isset($_POST['uploadedimage']))
{
// start of image
require "connection.php";
echo "debug hello entering function";
function GetImageExtension($imagetype)
{
echo "debug1";
if(empty($imagetype)) return false;
echo "debug2";
switch($imagetype)
{
case 'image/bmp': return '.bmp';
case 'image/gif': return '.gif';
case 'image/jpeg': return '.jpg';
case 'image/png': return '.png';
default: return false;
}
}
if (!empty($_FILES["uploadedimage"]["name"]))
{
$file_name=$_FILES["uploadedimage"]["name"];
$temp_name=$_FILES["uploadedimage"]["tmp_name"];
$imgtype=$_FILES["uploadedimage"]["type"];
$ext= GetImageExtension($imgtype);
$imagename=date("d-m-Y")."-".time().$ext;
echo "debug3";
$target_path = "image/".$imagename;
if(move_uploaded_file($temp_name, $target_path)) {
$query_upload="INSERT into `images_index` (images_path) VALUES
('".$target_path."')";
mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error());
echo "INSERT into `images_index` (images_path,submission_date) VALUES
('$target_path')";
echo "debug4";
}
else{
exit("Error While uploading image on the server");
}
}
}