How to auto resize uploaded image using php
I have a script;

            $fileName = $_FILES['userfile']['name'];
    		$tmpName = $_FILES['userfile']['tmp_name'];
    		$fileSize = $_FILES['userfile']['size'];
    		$fileType = $_FILES['userfile']['type'];
    		
    		// get the file extension first
    		$ext = substr(strrchr($fileName, "."), 1); 
    
    		// make the random file name
    		$randName = md5(rand() * time());
    		
    		// and now we have the unique file name for the upload file
    		$filePath = $imagesDir . $randName . '.' . $ext;
    		
    		$result = move_uploaded_file($tmpName, $filePath);
    		if (!$result) {
    			echo "Error uploading file";
    		exit;
    	} 
    	
    if(!get_magic_quotes_gpc()) {
    		
    		$fileName = addslashes($fileName);
    		$filePath = addslashes($filePath);
    		
    	}

which am using to upload images but I would like to add a script to resize the image to a specific size before it's uploaded. How do I do that???
How to auto resize uploaded image using php
===

I have a script;

            $fileName = $_FILES['userfile']['name'];
    		$tmpName = $_FILES['userfile']['tmp_name'];
    		$fileSize = $_FILES['userfile']['size'];
    		$fileType = $_FILES['userfile']['type'];
    		
    		// get the file extension first
    		$ext = substr(strrchr($fileName, "."), 1); 
    
    		// make the random file name
    		$randName = md5(rand() * time());
    		
    		// and now we have the unique file name for the upload file
    		$filePath = $imagesDir . $randName . '.' . $ext;
    		
    		$result = move_uploaded_file($tmpName, $filePath);
    		if (!$result) {
    			echo "Error uploading file";
    		exit;
    	} 
    	
    if(!get_magic_quotes_gpc()) {
    		
    		$fileName = addslashes($fileName);
    		$filePath = addslashes($filePath);
    		
    	}

which am using to upload images but I would like to add a script to resize the image to a specific size before it's uploaded. How do I do that???