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['proper ty_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_imag es/$proper ty_id')))
{
mkdir("../property_images/ $property_ id", 0700);
}
//upload the images
if(isset($_POST['_upload'] ) && $_FILES['userfile']['size' ] > 0)
{
$target_path = "../property_images/$prope rty_id/".b asename( $_FILES['userfile']['name' ]);
$img_url= $property_id."/".basename( $_FILES['userfile']['name' ]);
if(move_uploaded_file($_FI LES['userf ile']['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!";
}
$property_id=$_GET['proper
//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_imag
{
mkdir("../property_images/
}
//upload the images
if(isset($_POST['_upload']
{
$target_path = "../property_images/$prope
$img_url= $property_id."/".basename(
if(move_uploaded_file($_FI
/* echo "The file ". basename( $_FILES['userfile']['name'
" has been uploaded";*/
} else{
echo "There was an error uploading the file, please try again!";
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
http://www.phpclasses.org/browse/package/1476.html