<?php
session_start();
<?php
session_start();
require('connect.php');
if(isset($_SESSION['username']))
{
$dir="image/";
$file_name=$dir.basename($_FILES['uploads']['name']);
$fileUpload=1;
$imageType=pathinfo($file_name,PATHINFO_EXTENSION);
$image= addslashes(file_get_contents($_FILES['uploads']['tmp_name']));
$image_name = addslashes($_FILES['uploads']['name']);
$image_size = getimagesize($_FILES['uploads']['tmp_name']);
if(move_uploaded_file($_FILES['uploads']['tmp_name'], $file_name))
{
echo "uploaded succesfully" ;
echo "<img src='$file_name' width='50px' height='50px'>";
$querry="SELECT image FROM users WHERE username='$username'" or die(mysql_error());
$result=mysql_query($querry) or die(mysql_error());
$row=mysql_fetch_assoc($result) or die(mysql_error());
$oldimage=$row['image'];
unlink('directory/image/'.$oldimage);
/* $deleter = "DELETE FROM users WHERE image = '$oldimage'";
if(mysql_query($deleter)) {
echo "Successful!";
} */
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($file_name);
}
$sql="UPDATE users SET image='$fileName' WHERE image='$oldimage'";
$result=mysql_query($sql) or die(mysql_error());
if($result)
{
echo "created successfully";
echo "<br>";
echo "<a href='homeprofile.php'>Go back to home page</a>";
}
else
{
echo "cant create";
}
}
}
?>