Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

PHP file upload

$
0
0

Hey guys does anyone know why this doesnt upload large files? 6/7mb... the PHP ini files seem fine... i even overdone it by 

upload_max_filesize = 20M;

post_max_size = 20M;
max_execution_time = 400;
max_input_time = 400;
memory_limit = 900M;
 
was over the top but was just trying to find answer... i have the code here and attaching a full code thing.
 
	$src1 = '../../image_uploads/layout_uploads/temp/temp/'.$image_name.'.jpg';
			$src2 = '../../image_uploads/layout_uploads/temp/'.$image_name.'.jpg';

			// Get Rid Of Old Files
			unlink($src1);
			if(!empty($src2)){
				unlink($src2);
			}
			
			move_uploaded_file($_FILES["img_upload"]["tmp_name"], $src1);
			
			// INIT
			list($old_width, $old_height) = getimagesize($src1);
			
			if($old_width > $old_height){
				$total_w = $old_width;
				$total_h = $old_width;
				$image_top1 = $total_h - $old_height;
				$image_top2 = $image_top1 * 0.5;
				$image_top = $image_top2;
				$image_left = 0;
			} else {
				$total_w = $old_height;
				$total_h = $old_height;
				$image_left1 = $total_w - $old_width;
				$image_left2 = $image_left1 * 0.5;
				$image_top = 0;
				$image_left = $image_left2;
			}
			
			$create_bg = imagecreatetruecolor($total_w,$total_h); // Full Blue
			
			// CREATE WHITE BG
			$white = imagecolorallocate($create_bg, 255, 255, 255);
			imagefilledrectangle($create_bg, 0, 0, $total_h, $total_w, $white);
			
			// GET IMAGE
			$create_image = imagecreatefromjpeg($src1);
			
			// CREATE IMAGE
			imagecopyresampled($create_bg, $create_image, $image_left, $image_top, 0, 0, $old_width, $old_height, $old_width, $old_height);

			// OUTPUT
			if(filesize($src1) > 2000000){
				imagejpeg($create_bg, $src2, 60);
			} else if(filesize($src1) < 2000000 && filesize($src1) > 1000000){
				imagejpeg($create_bg, $src2, 70);
			} else if(filesize($src1) < 1000000 && filesize($src1) > 100000){
				imagejpeg($create_bg, $src2, 80);
			} else if(filesize($src1) < 100000 && filesize($src1) > 50000){
				imagejpeg($create_bg, $src2, 90);
			} else {
				imagejpeg($create_bg, $src2, 95);
			}
			
			unlink($src1);

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles