Jump to content

Upload several images and save in mysql table


Go to solution Solved by ginerjm,

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.