You may be running out of memory as the script is running. Add this line at the top:
# set the memory limit
ini_set('memory_limit','500M');
This will increase the memory this script uses.
You also might try uploading the photo and then creating the image, like this:
$path = $_SERVER['DOCUMENT_ROOT'] . '/photos/';
if ( is_uploaded_file( $_FILES['upfile']['tmp_name'] ) ) {
$filename = $_FILES['upfile']['name'];
if (move_uploaded_file($_FILES['infile']['tmp_name'], $path.$filename)) {
@chmod($filename,0666);
error_reporting (E_ALL);
$abc = imagecreatefromjpeg($path.$filename); }
}
I haven't tested this, but it's the general idea. Upload the file, then create the image. If you've saved the initial width and height, you then change the dimensions like this:
error_reporting (E_ALL);
$abc = imagecreatefromjpeg($path.$filename);
$def = imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($def, $abc, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($def, $path.$filename, 95);
imagedestroy($abc);
imagedestroy($def);