Получение: допустимый объем памяти 33554432 байт исчерпан

Неустранимая ошибка: допустимый размер памяти 33554432 байт исчерпан (пытался выделить 12288 байт).

Это ошибка, которую я получаю, когда пытаюсь загрузить изображение примерно на 2,94 мб.

Когда я загружаю изображение на 100 кб, и поэтому он отлично работает. Почему это?

Как я могу сделать ограничение, поэтому, если вы загружаете байты xx, вы получите ошибку, которая слишком велика, поэтому я не получаю эту фатальную ошибку.

я начал делать это в форме

$max_file_size = 8388608; <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size ?>"> 

Вот моя загрузка файла:

 <?php include "dbc.php"; $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']); $uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'images/profilePhoto/'; $uploadForm = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'editProfile.php'; $uploadSuccess = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'home.php'; $fieldname = 'file'; // possible PHP upload errors $errors = array(1 => 'php.ini max file size exceeded', 2 => 'html form max file size exceeded', 3 => 'file upload was only partial', 4 => 'no file was attached'); // check the upload form was actually submitted else print form isset($_POST['submit']) or error('You need to upload a profilephoto, no?', $uploadForm); // check for standard uploading errors ($_FILES[$fieldname]['error'] == 0) or error($errors[$_FILES[$fieldname]['error']], $uploadForm); // check that the file we are working on really was an HTTP upload @is_uploaded_file($_FILES[$fieldname]['tmp_name']) or error('not an HTTP upload', $uploadForm); // validation... since this is an image upload script we // should run a check to make sure the upload is an image @getimagesize($_FILES[$fieldname]['tmp_name']) or error('only image uploads are allowed', $uploadForm); // make a unique filename for the uploaded file and check it is // not taken... if it is keep trying until we find a vacant one $now = time(); while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name'])) { $now++; } // now let's move the file to its final and allocate it with the new filename makeThumbnail($_FILES[$fieldname], 122, 160, $v[id]); @move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename) or error('receiving directory insuffiecient permission', $uploadForm); $filnamn = $now.'-'.$_FILES[$fieldname]['name']; mysql_query("UPDATE users_profile SET photo = '$filnamn' WHERE uID = '$v[id]'") or die(mysql_error()); // If you got this far, everything has worked and the file has been successfully saved. // We are now going to redirect the client to the success page. echo "Du har nu bytt profillbild!"; // make an error handler which will be used if the upload fails function error($error, $location, $seconds = 5) { header("Refresh: $seconds; URL=\"$location\""); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n". '"http://www.w3.org/TR/html4/strict.dtd">'."\n\n". '<html lang="en">'."\n". ' <head>'."\n". ' <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n". ' <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n". ' <title>Upload error</title>'."\n\n". ' </head>'."\n\n". ' <body>'."\n\n". ' <div id="Upload">'."\n\n". ' <h1>Upload failure</h1>'."\n\n". ' <p>An error has occured: '."\n\n". ' <span class="red">' . $error . '...</span>'."\n\n". ' The upload form is reloading</p>'."\n\n". ' </div>'."\n\n". '</html>'; exit; } // end error handler ?> 

Функция MakeThumbnail ()

 function makeThumbnail($file, $thumbSizeWidth, $thumbSizeHeight, $user) { if ($file['error'] !== UPLOAD_ERR_OK) { // something blew up // so handle error condition // // error codes documentation: http://php.net/manual/en/features.file-upload.errors.php die(); } $path_thumbs = "images/profilePhoto/thumbs/"; $allowed_types = array('image/jpeg', 'image/jpg', 'image/bmp', 'image/png', 'image/gif'); $imageinfo = getimagesize($file['tmp_name']); // get image info list($width, $height, $type, $attr) = $imageinfo; if ($imageinfo === FALSE) { die("Uhoh. Unable to read uploaded file"); } if (!in_array($imageinfo['mime'], $allowed_types)) { die("Sorry, images of type {$imageinfo['mime']} not allowed"); } $rand_name = rand(0, 999999999); // this isn't particularly well done, but ... // create thumbnail switch($imageinfo['mime']) { case 'image/jpeg': case 'image/jpg': $new_img = imagecreatefromjpeg($file['tmp_name']); $file_ext = '.jpg'; break; case 'image/gif': $new_img = imagecreatefromgif($file['tmp_name']); $file_ext = '.gif'; break; case 'image/png': $new_img = imagecreatefrompng($file['tmp_name']); $file_ext = '.png'; break; default: die("Uhoh. How did we get here? Unsupported image type"); } $imgratio = $height / $width; $newwidth = $thumbSizeWidth; $newheight = $thumbSizeHeight; $resized_img = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); $thumb_name = $rand_name . $file_ext; $thumb_path = $path_thumbs . '/' . $rand_name . $file_ext; imagejpeg($resized_img, $thumb_path); mysql_query("UPDATE users_profile SET photo_thumb = '$thumb_name' WHERE uID = '$user'") or die(mysql_error()); imagedestroy($resized_img); imagedestroy($new_img); return($thumb_name); } 

Solutions Collecting From Web of "Получение: допустимый объем памяти 33554432 байт исчерпан"