A
Anonymous
Guest
hi,all i have a problem...i am uploading an image...it successfully uploading...but my requirement is whenever i want to upload a large image it will resize and then only it has to be upload...my code is...
<?php
ob_start(); session_start();
include ("includes/common.php");
include("includes/authentication.php");
include("includes/dbconfig.php");
include("SimpleImage.php");
$module = "profile"; //IMP don't change
$id=$_SESSION['userid'];
//echo "SELECT * FROM users where id='$id'";
if($_POST[submit] == "save")
{
$fullname=$_POST['fullname'];
$email=$_POST['email'];
$location=$_POST['location'];
$path = "profile_image/" . $_FILES["file"]["name"];
$error=0;
if($_POST['fullname'] == "")
{
$fullname_error="name cannot be left blank";
$error = 1;
}
if($_POST['email'] == "")
{
$email_error="email cannot be left blank";
$error = 1;
}
$pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
if (eregi($pattern, $email)==false)
{
$email_error="enter a valid email adress";
$error = 1;
}
if($_POST['location'] == "")
{
$location_error="location cannot be left blank";
$error = 1;
}
if($error==0)
{
$result=mysql_query("SELECT id FROM users WHERE email='$email' AND id!=".$_SESSION['userid']);
$num_rows=mysql_num_rows($result);
if($num_rows > 0)
{
$error = 2;
/* $row = mysql_fetch_row($result);
$id_2=$row['id'];
if($id == $id_2)
{
}
else
{
echo $email_error="already exits";
$error = 1;
}*/
}
else
{
$result1=mysql_query("UPDATE users
SET full_name='$_POST[fullname]', email='$_POST',location='$_POST[location]' WHERE id=$id");
/*echo "<pre>";
print_r($_FILES["file"]["size"]); */
if ( (is_uploaded_file($_FILES['file']['tmp_name'])) &&(($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"] < 20000))
{
if(move_uploaded_file($_FILES["file"]["tmp_name"], "profile_image/" . $_FILES["file"]["name"]))
{
//echo GetImageSize("profile_image/" . $_FILES["file"]["name"]);
/*$tmpimg = tempnam("/tmp", "MKUP");
system("djpeg $imgfile >$path");
system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$path");
unlink($tmpimg);*/
$result1=mysql_query("UPDATE users SET picture='$path' WHERE id=$id");
}
}
else if($_FILES["file"]["tmp_name"]!='')
{
echo $error=3;
}
//echo "saved successfully";//header("location:contactimage1.php");
}
//echo "saved successfully";//header("location:contactimage1.php");
}
}//end of if
$result = mysql_query("SELECT * FROM users where id='$id'");
while($row = mysql_fetch_array($result))
{
$fullname= $row['full_name'];
$email = $row['email'];
$location = $row['location'];
$imgpath = $row['picture'];
}
?>
this is my code the problem is at only uploading image...pls check my code once...and how i will resize my uploaded image and how it will dispaly......in my code fileuploading is workng..pls explain resizing of A IMAGE.....
<?php
ob_start(); session_start();
include ("includes/common.php");
include("includes/authentication.php");
include("includes/dbconfig.php");
include("SimpleImage.php");
$module = "profile"; //IMP don't change
$id=$_SESSION['userid'];
//echo "SELECT * FROM users where id='$id'";
if($_POST[submit] == "save")
{
$fullname=$_POST['fullname'];
$email=$_POST['email'];
$location=$_POST['location'];
$path = "profile_image/" . $_FILES["file"]["name"];
$error=0;
if($_POST['fullname'] == "")
{
$fullname_error="name cannot be left blank";
$error = 1;
}
if($_POST['email'] == "")
{
$email_error="email cannot be left blank";
$error = 1;
}
$pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
if (eregi($pattern, $email)==false)
{
$email_error="enter a valid email adress";
$error = 1;
}
if($_POST['location'] == "")
{
$location_error="location cannot be left blank";
$error = 1;
}
if($error==0)
{
$result=mysql_query("SELECT id FROM users WHERE email='$email' AND id!=".$_SESSION['userid']);
$num_rows=mysql_num_rows($result);
if($num_rows > 0)
{
$error = 2;
/* $row = mysql_fetch_row($result);
$id_2=$row['id'];
if($id == $id_2)
{
}
else
{
echo $email_error="already exits";
$error = 1;
}*/
}
else
{
$result1=mysql_query("UPDATE users
SET full_name='$_POST[fullname]', email='$_POST',location='$_POST[location]' WHERE id=$id");
/*echo "<pre>";
print_r($_FILES["file"]["size"]); */
if ( (is_uploaded_file($_FILES['file']['tmp_name'])) &&(($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"] < 20000))
{
if(move_uploaded_file($_FILES["file"]["tmp_name"], "profile_image/" . $_FILES["file"]["name"]))
{
//echo GetImageSize("profile_image/" . $_FILES["file"]["name"]);
/*$tmpimg = tempnam("/tmp", "MKUP");
system("djpeg $imgfile >$path");
system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$path");
unlink($tmpimg);*/
$result1=mysql_query("UPDATE users SET picture='$path' WHERE id=$id");
}
}
else if($_FILES["file"]["tmp_name"]!='')
{
echo $error=3;
}
//echo "saved successfully";//header("location:contactimage1.php");
}
//echo "saved successfully";//header("location:contactimage1.php");
}
}//end of if
$result = mysql_query("SELECT * FROM users where id='$id'");
while($row = mysql_fetch_array($result))
{
$fullname= $row['full_name'];
$email = $row['email'];
$location = $row['location'];
$imgpath = $row['picture'];
}
?>
this is my code the problem is at only uploading image...pls check my code once...and how i will resize my uploaded image and how it will dispaly......in my code fileuploading is workng..pls explain resizing of A IMAGE.....