cdoggg94 Posted May 25, 2012 Share Posted May 25, 2012 Basically what I want to know is if its possible to take this upload code: <?php set_time_limit(0); require_once("Connections/myConnect.php"); mysql_select_db("phpmy1_norfolkartscentre_ca"); $preName = $_POST['name']; $preText = $_POST['text']; $preLink = $_POST['links']; if(isset($_FILES['picture'])){ foreach($_FILES['picture']['tmp_name'] as $key => $tmp_name){ move_uploaded_file($tmp_name, "data/{$_FILES['picture']['name'][$key]}"); } //print_r($_FILES); $pre_banner = $_FILES['picture']['name'][0]; $pre_logo1 = $_FILES['picture']['name'][1]; $pre_logo2 = $_FILES['picture']['name'][2]; $pre_logo3 = $_FILES['picture']['name'][3]; $pre_scale1 = $_FILES['picture']['name'][4]; $pre_scale2 = $_FILES['picture']['name'][5]; $pre_scale3 = $_FILES['picture']['name'][6]; $pre_scale4 = $_FILES['picture']['name'][7]; $pre_scale5 = $_FILES['picture']['name'][8]; $pre_scale6 = $_FILES['picture']['name'][9]; $pre_scale7 = $_FILES['picture']['name'][10]; $pre_scale8 = $_FILES['picture']['name'][11]; $pre_scale9 = $_FILES['picture']['name'][12]; $querystring = "INSERT INTO presentation_tbl(pre_id,pre_name,pre_banner,pre_text,pre_link,pre_logo1,pre_logo2,pre_logo3,scale_1,scale_2,scale_3,scale_4,scale_5,scale_6,scale_7,scale_8,scale_9) VALUES(NULL,'".$preName."','".$pre_banner."','".$preText."','".$preLink."','".$pre_logo1."','".$pre_logo2."','".$pre_logo3."','".$pre_scale1."','".$pre_scale2."','".$pre_scale3."','".$pre_scale4."','".$pre_scale5."','".$pre_scale6."','".$pre_scale7."','".$pre_scale8."','".$pre_scale9."')"; $doquery = mysql_query($querystring); echo ""; }else{ echo "there was a problem uploading, please try again!"; } and make it do (for each file..) what this code: if(!isset($picture)) echo ""; else { $image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); $image_name = addslashes($_FILES['image']['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); $max_width = 250; $max_height = 377; list($width, $height) = $image_size; //echo $width.",".$height; $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); // New dimensions $mywidth = intval($ratio*$width); $myheight = intval($ratio*$height); does for one file Quote Link to comment https://forums.phpfreaks.com/topic/263136-upload-image-resize-on-multiple-files/ Share on other sites More sharing options...
mrMarcus Posted May 25, 2012 Share Posted May 25, 2012 Only one way to find out... give it a try! Honestly though, that's the best way to get a deep understanding of PHP. And yes, it will work. Piece together some code, give it a shot. Any problems, report back. Quote Link to comment https://forums.phpfreaks.com/topic/263136-upload-image-resize-on-multiple-files/#findComment-1348634 Share on other sites More sharing options...
cdoggg94 Posted May 25, 2012 Author Share Posted May 25, 2012 haha.. Alright, but im not really even sure where to start so if i do its gonna look a little funky. Quote Link to comment https://forums.phpfreaks.com/topic/263136-upload-image-resize-on-multiple-files/#findComment-1348636 Share on other sites More sharing options...
cdoggg94 Posted May 25, 2012 Author Share Posted May 25, 2012 So this is kind of what I have: if(isset($_FILES['picture'])){ foreach($_FILES['picture']['tmp_name'] as $key => $tmp_name){ $image = addslashes(file_get_contents($_FILES['picture']['tmp_name'])); $image_name = addslashes($_FILES['image']['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); $max_width = 250; $max_height = 377; list($width, $height) = $image_size; //echo $width.",".$height; $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); // New dimensions $mywidth = intval($ratio*$width); $myheight = intval($ratio*$height); move_uploaded_file($tmp_name, "data/{$_FILES['picture']['name'][$key]}"); } print_r($_FILES)." ".$ratio."\r\n"; $pre_banner = $_FILES['picture']['name'][0]; $pre_bannerH = ; $pre_bannerW = ; $pre_logo1 = $_FILES['picture']['name'][1]; $pre_logo2 = $_FILES['picture']['name'][2]; $pre_logo3 = $_FILES['picture']['name'][3]; $pre_scale1 = $_FILES['picture']['name'][4]; $pre_scale2 = $_FILES['picture']['name'][5]; $pre_scale3 = $_FILES['picture']['name'][6]; $pre_scale4 = $_FILES['picture']['name'][7]; $pre_scale5 = $_FILES['picture']['name'][8]; $pre_scale6 = $_FILES['picture']['name'][9]; $pre_scale7 = $_FILES['picture']['name'][10]; $pre_scale8 = $_FILES['picture']['name'][11]; $pre_scale9 = $_FILES['picture']['name'][12]; It does appear to print the sizes on the images that have been uploaded. But how do i get the content for the: $pre_bannerH = ; and $pre_bannerW = ; variables? Would it be something like: $pre_bannerH = $myheight[0]; ? Quote Link to comment https://forums.phpfreaks.com/topic/263136-upload-image-resize-on-multiple-files/#findComment-1348643 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.