Jump to content

Upload several images and save in mysql table


jkkenzie

Recommended Posts

I receive files/images and loop through an array as follows:

$files=rearrfiles( $_FILES['image']);
    foreach($files as $key=>$item)
    {
	  if(is_array($item) && !empty($item['name']) && !empty($item['tmp_name'])){
		  //$_POST['imageFile']=$item['name'];
		 //echo $item['name'];
		  if($error!=true && !uploadImageB(array('image'=>'image'), DB_EXTENTION."mod_projects_images", $naming, $search = $editId,  $dir, 'photo'))
		  {			
		   $error=true;
		   $action='Edit';
		   $message.='<br>Images were unable to be uploaded.';
		  } 

	  }
	}

The function uploadImageB() is as follows:

function uploadImageB($info, $table, $naming, $search, $path, $add='uploaded', $maxw=1280, $maxh=1280, $dynamic=true, $id='Id', $thumbMaxWidth = 120)
{
 global $connection;
 if(!$_POST){ global $HTTP_POST_VARS; @$_POST=$HTTP_POST_VARS;}
 if(!$_FILES){ global $HTTP_POST_FILES; @$_FILES=$HTTP_POST_FILES;}
 if(is_array($info) && !empty($info) && $table!='' && !empty($path))
 {

	$error=false;
    $d=$naming;
	foreach($info as $key=>$val)
	{		

	 $names[$val]=$dynamic==true?$add.'_'.$result[$id].'_'.$d.'_.'.strtolower(mygetext($_FILES[$val]['name'])):$add.strtolower(mygetext($_FILES[$val]['name']));
	
		 if(is_array(@$_FILES[$val]) && !empty($_FILES[$val]['name']) && !empty($names[$val]))
		 {
				if(!singMove($path, $names[$val], $_FILES[$val], array(), array('gif', 'jpeg', 'jpg', 'png', 'bmp', 'svg')))
				{
					$error=true; break;
				}
			else{
					$valid[$val]=$names[$val];
					resizeImage($path.$names[$val], $maxw, $maxh);
					make_thumb($path.$names[$val],$names[$val], $path, $thumbMaxWidth);
				}
		 }

	}
	
	
	if($error==true) return false;
	elseif(!empty($valid))
	{
  
	 $connection->info=$info; $connection->input=$valid; $connection->id=array('field'=>$id, 'val'=>addslashes($result[$id]));
	 $connection->makenew($table); $connection->return_db($connection->query);
	}
 }
 return true;
}

I get the error:

Images were unable to be uploaded.

Any help?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.