Link to home
Start Free TrialLog in
Avatar of roscoeh23
roscoeh23

asked on

upload and resize and image with PHP

I am trying to upload an image to a folder and resize it to 400px by 300px on the way. At the moment it just upload the full size image to my folder. Can anybody help?





$property_id=$_GET['property_id'];

//home many images are in the table
$result = mysql_query("SELECT * FROM images WHERE property_id='$property_id'");
$num_rows = mysql_num_rows($result);


if(!(is_dir('property_images/$property_id')))
{
mkdir("../property_images/$property_id", 0700);

}

//upload the images

if(isset($_POST['_upload'])  && $_FILES['userfile']['size'] > 0)
{




$target_path = "../property_images/$property_id/".basename( $_FILES['userfile']['name']);

$img_url= $property_id."/".basename( $_FILES['userfile']['name']);

if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) {
  /*  echo "The file ".  basename( $_FILES['userfile']['name']).
    " has been uploaded";*/
} else{
    echo "There was an error uploading the file, please try again!";
}
Avatar of babuno5
babuno5
Flag of India image

this php class can suite your requirement
http://www.phpclasses.org/browse/package/1476.html
ASKER CERTIFIED SOLUTION
Avatar of siva_siva
siva_siva
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tbeasley123
tbeasley123

What could be the case if the accepted solution script above and similar like are crashing my server? I am using the code above that "siva siva" entered.