views:

61

answers:

0

I have been working on a script that uploads an image to a server and add a reference to that Image in a database.
The server runs a PHP4 version on apache ( and there is no chance to upgrade )
So I wanna modify the following upload script to resize the image automatically

<?php 
                          include_once('CheckLogin.php');
                          include_once('LoginLogoutLink.php');
                          ?>

                          </td>
                        </tr>
                        <tr>
                          <td>
                            <?php

include_once('db_con.php');
$feedback = '';
if(isset($_POST['UploadImage']))
{

$result = '';
$query = '';
$un = $_SESSION['username'];
$imageURL= $_POST['imageURL'];
$ct = $_POST['categorylist'];
$photo = '';

$MemberName = $_POST['MemberName'];
$Title = $_POST['Title'];
$Bike = $_POST['Bike'];
$EventName = $_POST['EventName'];
$Date = $_POST['Date'];
$ClubName = $_POST['ClubName'];
$Location = $_POST['Location'];
    if(isset($_FILES['userfile']['name']) && $_FILES['userfile']['name'] != "")
        {
            $size = getimagesize($_FILES['userfile']['tmp_name']);
            $w = $size[0];
            $h = $size[1];          

                $uploaddir = 'allimages/';              
                $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);


                if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
                {
                    chmod($uploadfile,0755);
                    $photo = $uploadfile;                   
                    $query = "insert into userpictures
                            (category,uploadpicname,imageURL,MemberName,Title,Bike,EventName,Date,ClubName,location) 
                            values ('$ct','$photo','$imageURL','$MemberName','$Title','$Bike','$EventName','$Date','$ClubName','$Location') ";

                    $result = mysql_query($query);

                    if($result)
                    {
                        $feedback = 'Image Uploaded Successfully';              
                    }
                    else
                    {
                        die('Database Error');
                    }
                }
                else
                {
                    $feedback = 'Uploaded Image Is Not Valid!';                     
                }

        }
        else
        {
            $feedback = 'Please Select Image!';
        }

}
?>